#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
 char vec[1000000];
  int m, n;
struct p
{
	int x,y;
};
int mmax = 0;
int cur = 1;
void go(int x, int y)
{
  cur++;
  int max_t = 1;
  //vec[x][y] = 0;
  vec[x * (n) + y] = '0';
  vector <p> a;
  p t;
  t.x = x;
  t.y = y;
  a.push_back(t);
  while(!a.empty())
  {
	  t = a[a.size() - 1];
	  a.pop_back();
	  x = t.x;
	  y = t.y;
  if (x > 0)
  {
	  if (vec[(x - 1) * n + y] == '1')
	  {
		  vec[(x - 1) * n + y] = '0';
		  max_t++;
		  p t;
		  t.x = x - 1;
		  t.y = y;
		  a.push_back(t);
	  }
  }
  if (x < m - 1)
  {
	 if (vec[(x + 1) * n + y] == '1')
	  {
		  vec[(x + 1) * n + y] = '0';
		  max_t++;
		  p t;
		  t.x = x + 1;
		  t.y = y;
		  a.push_back(t);
	  }
  }
   if (y < n - 1)
  {
	 if (vec[(x) * n + y + 1] == '1')
	  {
		  vec[(x) * n + y + 1] = '0';
		  max_t++;
		  p t;
		  t.x = x ;
		  t.y = y + 1;
		  a.push_back(t);
	  }
  }
    if (y > 0)
  {
	 if (vec[(x) * n + y - 1] == '1')
	  {
		  vec[(x) * n + y - 1] = '0';
		  max_t++;
		  p t;
		  t.x = x ;
		  t.y = y - 1;
		  a.push_back(t);
	  }
  }
  mmax = max(mmax, max_t); 
}
}
int main()
{
  
 
  
  //freopen("in.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  cin >> m >> n;
  
  for(int i = 0; i < m * n + 1; i++)
	  cin >> vec[i];
  /*for(int i = 0; i < m; i ++)
  {
	  for(int j = 0; j < n; j++)
		  cout << vec[i * (n) + j];
  cout << endl;
  }*/

for(int i = 0; i < m; i ++)
	  for(int j = 0; j < n; j++)
		 if (vec[i * n + j] == '1')
			  go(i, j);  

  
  
  
  /*  for(int j = 0; j < n; j++)
	  {
		  if (vec[i][j])
			  go(i, j);
	  }*/
  cout << cur - 1 << ' ' << mmax;
  return 0;
}