var x,c,c1,n,m,i,j,k:integer;
    a: array [1..100,1..100] of integer;
    s:string;
    procedure  dr(i,j:integer);
    begin
    a[i,j]:=2;
    c:=c+1;
    if (a[i+1,j]=1) then dr(i+1,j);
    if (a[i-1,j]=1) then dr(i-1,j);
    if (a[i,j+1]=1) then dr(i,j+1);
    if (a[i,j-1]=1) then dr(i,j-1);
    end;
begin
readln(m,n);
for i:=1 to m do
begin
s:='';
readln(s);
for j:=1 to n do
begin
val(s[j],a[i+2,j+2],k);
end;
end;
x:=0; c1:=0;
for i:=1 to m+2 do
for j:=1 to n+2 do
begin
c:=0;
if (a[i,j]=1) then begin dr(i,j);
if c>c1 then c1:=c;
x:=x+1;   end;end;
write(x,' ',c1);
end.
