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

using namespace std;

char **map;
bool **mapbool;
int n,m;

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')
		{
			int cur = 0;
			
			queue<int> q;
			q.push(i);
			q.push(j);
			while(!q.empty())
			{
				int curi = q.front();
				q.pop();
				int curj = q.front();
                q.pop();
	    		mapbool[curi][curj] = true;
	         cur++;
			 if(curi+1<m&&map[curi+1][curj]=='1'&&mapbool[curi+1][curj]==false) {q.push(curi+1);q.push(curj);}
             if(curi-1>=0&&map[curi-1][curj]=='1'&&mapbool[curi-1][curj]==false) {q.push(curi-1);q.push(curj);}
             if(curj+1<n&&map[curi][curj+1]=='1'&&mapbool[curi][curj+1]==false) {q.push(curi);q.push(curj+1);}
             if(curj-1>=0&&map[curi][curj-1]=='1'&&mapbool[curi][curj-1]==false) {q.push(curi);q.push(curj-1);}
			}

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

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

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

