program Project2;

type  ref=^node;
      node=record
        dc:longint;
        up:ref;
        last:ref;
        right:ref;
      end;

var   i, j, a:longint;
      c:char;
      p, q:node;
      y, x, m, my:longint;

var f, g:text;

function rec(p:ref):longint;
var i:longint;
    ny, c, a, m:longint;
begin
    ny:=y+1;
    m:=0; c:=0;
    if (p<>nil) then
      for i:=1 to p^.dc do begin
        inc(c);
        a:=rec(p^.down[i]);
        if a+c>m then m:=a+c;
        end;
      end;
    Result:=m;
end;

function newp(up:ref):ref;
begin
  new(Result);
  Result^.dc:=0;
  Result^.up:=up;
end;

procedure addp(p, q:ref);
begin
  inc(p^.dc);
  if (p^.right=nil) then
    p^.right:=ref
  else p^.last^.right:=ref;
  p^.last:=ref;
end;

begin
    assign(f, 'input.txt');
    reset(f);
    for i:=1 to 10001 do mas[i].w:=0;
    mas[0].w:=1;
    i:=0; j:=0; y:=0; my:=0;
    p:=newp(nil);
    while not eof(f) do begin
      read(f, c);
      case c of
        'd':begin
              y:=y+1;
              if y>my then my:=y;
              q:=newp(p);
              addp(p, q);
              p:=p^.last;
           end;
        'u':begin
            p:=p^.up;
            y:=y-1;
            end;
      end;
    end;
    close(f);

    m:=rec(1, 0);

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