#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
 vector <vector<char>> vec;
  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] = cur;
  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][y] == '1')
	  {
		  vec[x - 1][y] = cur;
		  max_t++;
		  p t;
		  t.x = x - 1;
		  t.y = y;
		  a.push_back(t);
	  }
  }
  if (x < m - 1)
  {
	 if (vec[x + 1][y] == '1')
	  {
		  vec[x + 1][y] = cur;
		  max_t++;
		  p t;
		  t.x = x + 1;
		  t.y = y;
		  a.push_back(t);
	  }
  }
   if (y < n - 1)
  {
	 if (vec[x][y + 1] == '1')
	  {
		  vec[x][y + 1] = cur;
		  max_t++;
		  p t;
		  t.x = x ;
		  t.y = y + 1;
		  a.push_back(t);
	  }
  }
    if (y > 0)
  {
	 if (vec[x][y - 1] == '1')
	  {
		  vec[x][y - 1] = cur;
		  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;
  vec.resize(m);
  for(int i = 0; i < m; i++)
	  for(int j = 0; j < n; j++)
	  {
		  char b;
		  cin >> b;
	      vec[i].push_back(b);
	  }
  for(int i = 0; i < m; i++)
	  for(int j = 0; j < n; j++)
	  {
		  if (vec[i][j] == '1')
			  go(i, j);
	  }
  cout << cur - 1 << ' ' << mmax;
  return 0;
}