program Project2;

{$APPTYPE Console}

type  ref=^node;
      node=record
        left, right:ref;
      end;

var   i, j, a:integer;
      c:char;
      mas:array[0..1001] of record
          w:integer;
          d:array[1..1000] of record
              l, r, u:integer;
          end;
      end;
      num:array[1..1000] of integer;
      y, x, m, my:integer;

var f, g:text;

function rec(x, y:integer):integer;
var i:integer;
    ny, c, a, m:integer;
begin
    ny:=y+1;
    m:=0; c:=0;
    for i:=1 to mas[ny].w do begin
      if mas[ny].d[i].u=x then begin
        inc(c);
        a:=rec(i, ny);
        if a+c>m then m:=a+c;
      end;
    end;
    Result:=m;
end;

begin
    assign(f, 'input.txt');
    reset(f);
    for i:=0 to 1001 do mas[i].w:=0;
    i:=0; j:=0; y:=0; my:=0;
    while not eof(f) do begin
      read(f, c);
      case c of
        'd':begin
              y:=y+1;
              if y>my then my:=y;
              inc(mas[y].w);
              mas[y].d[mas[y].w].l:=0;
              mas[y].d[mas[y].w].r:=0;
              mas[y].d[mas[y].w].u:=mas[y-1].w;
           end;
        'u':y:=y-1;
      end;
    end;

    m:=rec(0, 0);

    assign(g, 'output.txt');
    rewrite(g);
    writeln(g, my, ' ', m);
    close(g);
end.
