#include <iostream>
#include <cstdio>

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

#include <vector>

using namespace std;

#define pb(x) push_back(x)

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 dfs (int x, int y) {
	if (a[x][y] != '1') return 0;

	int res = 1;
	a[x][y] = '0';
	for (int i = 0; i < 4; i++) if (ok (x + dx[i], y + dy[i]))
		res += dfs (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);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int c; scanf ("%c", &c);
			a[i].pb (c);
		}
		scanf ("\n");
	}

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

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

	return 0;
}