program trot;
type
rec=record
l,r,w,f:longint;
end;
var
ss:ansistring;
i,j,p,l,min,max,now:longint;
tree:array[0..10005]of rec;
procedure init;
begin
assign(input,'trot.in');
reset(input);
assign(output,'trot.out');
rewrite(output);
readln(ss);
l:=length(ss);
max:=-1;
min:=maxlongint;
end;
procedure closef;
begin
close(input);
close(output);
end;
procedure settree(fa:longint);
begin
inc(p);
if p>l then exit;
if ss[fa]='1' then
begin
tree[fa].l:=p;
tree[p].f:=fa;
settree(p);
end else if ss[fa]='2' then
begin
tree[fa].l:=p;
tree[p].f:=fa;
settree(p);
inc(p);
tree[fa].r:=p;
tree[p].f:=fa;
settree(p);
end;
if ss[fa]='0' then
begin
dec(p);
exit;
end;
end;
procedure bl(x:longint);
var
i:integer;
flg:boolean;
begin
if x=p-1 then
begin
if now>max then max:=now;
if now<min then min:=now;
exit;
end;
flg:=false;
for i:=1 to 3 do if i<>tree[tree[x].f].w then
begin
if i=2 then flg:=true;
tree[x].w:=i;
if i=2 then inc(now);
if tree[x].l<>0 then bl(tree[x].l);
if tree[x].r<>0 then bl(tree[x].r);
end;
if flg then dec(now);
end;
procedure main;
begin
fillchar(tree,sizeof(tree),0);
p:=1;
settree(1);
now:=0;
bl(1);
writeln(max,' ',min);
end;
begin
init;
main;
closef;
end.