#include <stdio.h>

int color=1;
char W;
char H;
char **cn;
int *sum;

int cmpp(char *str,int h)
{int f=0;
  while(str[f]!=0)
  {f++;}
  if(f==h){f=1;}else{f=0;}
  return f;
}


void paint(char h,char w)
{
 cn[h][w]=color;
 sum[color]++;
 if(h>0){
 if((cn[h-1][w]!=color)&&(cn[h-1][w]!=0)){
	 paint(h-1,w);
 }
 }
 if(w<W-1){
 if((cn[h][w+1]!=color)&&(cn[h][w+1]!=0)){
	 paint(h,w+1);
 }
 }
 if(h<H-1){
 if((cn[h+1][w]!=color)&&(cn[h+1][w]!=0)){
	 paint(h+1,w);
 }
 }
 if(w>0)
 {if((cn[h][w-1]!=color)&&(cn[h][w-1]!=0)){
	 paint(h,w-1);
 }
 }
}


int main()
{
char i, j,b;
char *str;
scanf("%d %d",&H,&W);
str = new char [W+2];


cn = new char*[H];
sum=new int[(H*W)/2];

for(i=0;i<(H*W)/2;i++){sum[i]=0;}
for(i=0;i<H;i++)
{cn[i]=new char [W];}
i=0;
while(i!=H)
{ gets(str);
if(cmpp(str,W))
	{
	
  	for(j=0;j<W;j++) 
	{
		cn[i][j]=str[j]-48;
	}
	i++;
	}
}



//for(i=0;i<H;i++) {for(j=0;j<W;j++){cn[i][j]=0;}}

for(i=0;i<H;i++)
{
 for(j=0;j<W;j++)
  { if(cn[i][j]==1)
   {color++;paint(i,j);
   }
  }
}
j=0;
for(i=2;i<(H*W)/2;i++){if(j<sum[i]){j=sum[i];}}

printf("%d %d",color-1,j);
scanf("%d",&j);
delete sum;
delete[] cn;
return 0;

}