program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

Var
    i,j,plmax,sch,n,m:integer;
    a:array[0..1000,0..1000] of byte;
    c:string;
    c1,q,max:integer;
procedure rec(i,j:integer);
begin
      if a[i+1,j]<>1 then begin q:=q+1;end;
      if a[i,j+1]<>1 then begin q:=q+1; end;
      if a[i-1,j]<>1 then begin q:=q+1; end;
      if a[i,j-1]<>1 then begin q:=q+1; end;
      if q>=3 then begin a[i,j]:=0; plmax:=plmax+1; end;
      q:=0;
      if a[i+1,j]=1 then  begin i:=i+1; rec(i,j); end;
      if a[i,j+1]=1 then  begin j:=j+1; rec(i,j); end;
      if a[i-1,j]=1 then  begin i:=i-1; rec(i,j); end;
      if a[i,j-1]=1 then  begin j:=j-1; rec(i,j); end;

end;
begin
    read(n,m);
    sch:=0; plmax:=1;   max:=0;
    for i:=1 to n do
    begin
          readln(c1);
          c:=IntToStr(c1);
          q:=length(c);
          while q<m do
          begin
          c:='0'+c;
          q:=q+1;
          end;
          for j:=1 to m do
          begin
                a[i,j]:=StrToInt(c[j]);
          end;
    end;
    q:=0;
    for i:=1 to n do
    begin
        for j:=1 to m do
        begin
              if a[i,j]=1 then
              begin
               rec(i,j);
               If plmax>max then max:=plmax;
               plmax:=1;
               sch:=sch+1;
              end;
        end;
    end;
    writeln(max-1,'   ',sch);

end.
