var
n,count,max:integer;
begin
readln(n);
max:=n mod 10; count:=1;
n:=n div 10;
repeat
if n mod 10 > max then
begin
max:=n mod 10;
count:=1;
n:=n div 10;
end
else
if n mod 10 = max then
begin
inc(count);
n:=n div 10;
end
else
n:=n div 10;
until n<=0;
writeln(max,' ',count);
end.