#include<iostream>
#include<queue>
using namespace std;
// 二叉树的链式存储
typedef struct BiTNode{
char data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
// 先序遍历创建二叉树
void CreateBiTree(BiTree &T){
char ch;
cin>>ch;
if(ch=='#') T=NULL;
else{
T=new BiTNode;
T->data=ch;
CreateBiTree(T->lchild);
CreateBiTree(T->rchild);
}
}
// 求二叉树最大高度
int maxDepth(BiTree root){
if(root==NULL) return 0;
else{
return 1+max(maxDepth(root->lchild),maxDepth(root->rchild));
}
}
// 求二叉树的最小高度
int minDepth(BiTree root){
queue<BiTNode *> q;
// set<BiTNode> visited;
q.push(root);
// visited.insert(root);
int depth=1;
while(!q.empty()){
int sz=q.size();
for(int i=0;i<sz;++i){
BiTNode *cur=q.front();
q.pop();
if(cur->lchild==NULL && cur->rchild==NULL){
return depth;
}
if(cur->lchild!=NULL){
q.push(cur->lchild);
}
if(cur->rchild!=NULL){
q.push(cur->rchild);
}
}
++depth;
}
}
int main(){
BiTree T;
CreateBiTree(T);
cout<<maxDepth(T)<<endl;
cout<<minDepth(T);
return 0;
}