#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

char **map;
bool **mapbool;
int n,m;
int cur = 0;

void RecSearch(int i,int j)
{
	mapbool[i][j] = true;
	cur++;
    if(i+1<m&&map[i+1][j]=='1'&&mapbool[i+1][j]==false) RecSearch(i+1,j);
    if(i-1>=0&&map[i-1][j]=='1'&&mapbool[i-1][j]==false) RecSearch(i-1,j);
    if(j+1<n&&map[i][j+1]=='1'&&mapbool[i][j+1]==false) RecSearch(i,j+1);
    if(j-1>=0&&map[i][j-1]=='1'&&mapbool[i][j-1]==false) RecSearch(i,j-1); 
}

int main()
{ 
    cin>>m>>n;
	map = new char*[m];
mapbool = new bool*[m];
for(int i = 0;i<m;i++)
{
	map[i]= new char[n];
	mapbool[i]=new bool[n];
	for(int j=0;j<n;j++)
	{
		cin>>map[i][j];
		mapbool[i][j]=false;
	}
}
int max = 0;
int count = 0;
for(int i = 0;i<m;i++)
{
   for(int j=0;j<n;j++)
   {
    if(!mapbool[i][j])
		if(map[i][j]=='1')
		{
			cur = 0;
			RecSearch(i,j);
			if(cur>max) max = cur;
			count++;
		}
		else mapbool[i][j] = true;
   }
}

cout<<count<<" "<<max;

//system("Pause");
	return 0;
}

