var a,d,f,h:array[1..1000]of longint;
i,j,tot,l,r,n,mid,lis:longint;
begin
assign(input,'missile.in');reset(input);
assign(output,'missile.out');rewrite(output);
while not seekeof do
begin inc(n);read(a[n]);end;
for i:=n downto 1 do
begin
l:=1;r:=lis;
while l<=r do
begin
mid:=(l+r)shr 1;
if d[mid]<=a[i]then l:=mid+1 else r:=mid-1;
end;
dec(l);
if l+1>lis then lis:=l+1;
f[i]:=l+1;
if (a[i]<d[f[i]])or(d[f[i]]=0)then d[f[i]]:=a[i];
end;
writeln(lis);
for i:=1 to n do
begin
l:=0;
for j:=1 to tot do
if h[j]>=a[i]then begin h[j]:=a[i];l:=1;break;end;
if l=0 then begin inc(tot);h[tot]:=a[i];end;
end;
writeln(tot);
close(input);close(output);
end.