var
a,b,len:array[0..1000]of longint;
n,l,i,j,k,num:longint;
begin
assign(input,'missile.in');reset(input);
assign(output,'missile.out');rewrite(output);
while not eoln do
begin
inc(n);
read(a[n]);
len[n]:=1;
end;
readln;
for i:=n-1 downto 1 do
begin
l:=0;
for j:=i+1 to n do
if ((a[j]<a[i])and(len[j]>l)) then l:=len[j];
if l>0 then len[i]:=l+1;
end;
j:=1;
for i:=1 to n do
if len[i]>len[j] then j:=i;
writeln(len[j]);
num:=0;
b[0]:=maxlongint;
for i:=1 to n do
begin
k:=0;
for j:=1 to num do
if (b[j]>=a[i])and(b[j]<b[k]) then k:=j;
if k=0 then
begin
inc(num);
b[num]:=a[i];
end
else
b[k]:=a[i];
end;
writeln(num);
close(input);
close(output);
end.