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

using namespace std;

char **map;
int n,m;
int cur;

//void Rec(int curi,int curj)
//{
//	if(map[curi][curj]!='2'){
//				map[curi][curj]='2';
//				cur++;}
//			 if(curi+1<m&&map[curi+1][curj]=='1') Rec(curi+1,curj);
//             if(curi-1>=0&&map[curi-1][curj]=='1')  Rec(curi-1,curj);
//             if(curj+1<n&&map[curi][curj+1]=='1')  Rec(curi,curj+1);
//             if(curj-1>=0&&map[curi][curj-1]=='1')  Rec(curi,curj-1);
//}

int main()
{ 
	
    queue<int> q;
    cin>>m>>n;
	map = new char*[m];
for(int i = 0;i<m;i++)
{
	map[i]= new char[n];
	for(int j=0;j<n;j++)
	{
		cin>>map[i][j];
	}
}
int max = 0;
int count = 0;
for(int i = 0;i<m;i++)
{
   for(int j=0;j<n;j++)
   {
    if(map[i][j]!='2')
		if(map[i][j]=='1')
		{
			cur = 0;
			
			/*Rec(i,j);*/
			q.push(i);
			q.push(j);
			while(!q.empty())
			{
				int curi = q.front();
				q.pop();
				int curj = q.front();
                q.pop();
				if(map[curi][curj]!='2'){
				map[curi][curj]='2';
				cur++;}
			 if(curi+1<m&&map[curi+1][curj]=='1') {q.push(curi+1);q.push(curj);}
             if(curi-1>=0&&map[curi-1][curj]=='1') {q.push(curi-1);q.push(curj);}
             if(curj+1<n&&map[curi][curj+1]=='1') {q.push(curi);q.push(curj+1);}
             if(curj-1>=0&&map[curi][curj-1]=='1') {q.push(curi);q.push(curj-1);}
			}

			if(cur>max) max = cur;
			count++;
		}
		else map[i][j]=2;
   }
}

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

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

