// #pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define mp make_pair
#define ll long long
#define pb push_back

char str[2000000];
int num[2000000];

int n, m;
int **a;
int **d;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

void bfs(int x, int y, int curr) {
	queue< pair<int, int> > q;
	q.push(mp(x, y));

	while (!q.empty()) {
		int u = q.front().first;
		int v = q.front().second;
		q.pop();

		for (int i = 0; i < 4; i++) {
			int newu = u + dx[i];
			int newv = v + dy[i];

			if (newu >= 0 && newu < n &&
				newv >= 0 && newv < m &&
				a[newu][newv] == 1 &&
				d[newu][newv] == 0) {

				d[newu][newv] = curr;
				num[curr]++;
				q.push(mp(newu, newv));
			}
		}
	}
}

int main() {
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;

	a = new int*[n];
	d = new int*[n];
	for (int i = 0; i < n; i++) {
		a[i] = new int[m];
		d[i] = new int[m];
	}

	for (int i = 0; i < n; i++) {
		cin >> str;
		for (int j = 0; j < m; j++) {
			a[i][j] = str[j] == '1';
			d[i][j] = 0;
		}
	}

	memset(num, 0, sizeof(num));

	int count = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (d[i][j] == 0 && a[i][j] == 1) {
				num[count]++;
				d[i][j] = count;

				bfs(i, j, count);
				count++;
			}
		}
	}

	int mx = 0;

	for (int i = 0; i <= n * m; i++) {
		if (num[i] > mx) {
			mx = num[i];
		}
	}

	cout << count - 1 << ' ' << mx << endl;

	return 0;
}
/*
2 5
10001
10001

1 1
1

5 5
10000
01000
00100
00010
00001

6 7
1001001
1111011
1001000
1001111
0100000
0000000

4 4
0000
0000
0010
0000
*/