// one.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <cctype>
#include <string>
#include <vector>
#include <stack>

using namespace std;

typedef long long ll;

int gcount, cmax, N, M;
vector<vector<bool> > matrix;

stack<pair<int, int> > st;

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

	int i, j, y, x, tmax;
	char buffer[10100];
	pair<int, int> pr;

	scanf("%d %d", &M, &N);
	matrix.resize(M);
	for (i = 0; i < M; ++i) {
		matrix[i].resize(N);
		scanf("%s", buffer);
		for (j = 0; j < N; ++j) {
			if (buffer[j] == '1')
				matrix[i][j] = true;
			else
				matrix[i][j] = false;
		}
	}

	/*for (i = 0; i < M; ++i) {
		for (j = 0; j < N; ++j)
			cout << matrix[i][j] ? 1 : 0;
		cout << endl;
	}

	return 0; */

	for (i = 0; i < M; ++i) {
		for (j = 0; j < N; ++j) {
			if (matrix[i][j] == true) {
				++gcount;

				st.push(pair<int, int>(i, j));
				tmax = 0;
				while (!st.empty()) {
					pr = st.top();
					st.pop();
					
					y = pr.first;
					x = pr.second;

					if (matrix[y][x] == false)
						continue;

					++tmax;
					matrix[y][x] = false;
					if (y + 1 < M && matrix[y + 1][x] == true)
						st.push(pair<int, int>(y + 1, x));

					if (x + 1 < N && matrix[y][x + 1] == true)
						st.push(pair<int, int>(y, x + 1));

					if (y - 1 >= 0 && matrix[y - 1][x] == true)
						st.push(pair<int, int>(y - 1, x));

					if (x - 1 >= 0 && matrix[y][x - 1] == true)
						st.push(pair<int, int>(y, x - 1));
				}

				if (tmax > cmax)
					cmax = tmax;
			}
		}
	}

	cout << gcount << ' ' << cmax;

	return 0;
}

