#include <iostream>
#include <cstdio>

#include <algorithm>
#include <cmath>
#include <cstring>

#include <vector>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define pb(x) push_back(x)
#define mp(a, b) make_pair (a, b)

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n, m;

vector <vector <char> > a;

bool ok (int x, int y) {
	return x >= 0 && y >= 0 && x < n && y < m;
}

int bfs (int x, int y) {
	int res = 0;
	queue <pair <int, int> > q;
	q.push (mp (x, y));
	a[x][y] = '0';
	while (!q.empty ()) {
		pair <int, int> v = q.front (); q.pop ();
		x = v.first, y = v.second; res++;		
		for (int i = 0; i < 4; i++) {
			if (ok (x + dx[i], y + dy[i]) && a[x + dx[i]][y + dy[i]] == '1') {
				a[x + dx[i]][y + dy[i]] = '0'; 
				q.push (mp (x + dx[i], y + dy[i]));
			}
		}
	}
	
	return res;
}

int main () {
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);

	scanf ("%d%d\n", &n, &m);

	a.resize (n);

	int cnt = 0, ans = 0;	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c; scanf ("%c", &c);
			a[i].pb (c);
		}
		scanf ("\n");
	}

	for (int i = 0; i < n; i++) 
		for (int j = 0; j < m; j++) if (a[i][j] == '1') {
			cnt++;
			int x = bfs (i, j);
			if (x > ans) ans = x;
		}

	printf ("%d %d", cnt, ans);

	return 0;
}