program Project2;

type  ref2=pointer;
      node=record
        down:ref2;
        up:ref2;
        last:ref2;
        right:ref2;
      end;
      ref=^node;

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

var f, g:text;

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

function newp(up:ref):ref;
var c:ref;
begin
  new(c);
  c^.down:=nil;
  c^.up:=up;
  c^.right:=nil;
  c^.last:=nil;
  Result:=c;
end;

procedure addp(p:ref);
var q:ref;
begin
  q:=newp(p);
  if (p^.down=nil) then
    p^.down:=q
  else ref(p^.last)^.right:=q;
  p^.last:=q;
end;

begin
    assign(f, 'input.txt');
    reset(f);
    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;
              addp(p);
              p:=p^.last;
           end;
        'u':begin
              p:=p^.up;
              y:=y-1;
            end;
      end;
    end;
    close(f);

    m:=rec(p);

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