// 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>

using namespace std;

typedef long long ll;

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

ll func(int i, int j)
{
	ll result = 0;
	matrix[i][j] = false;

	if (i + 1 < M && matrix[i + 1][j] == true)
		result += func(i + 1, j);

	if (j + 1 < N && matrix[i][j + 1] == true)
		result += func(i, j + 1);

	if (i - 1 >= 0 && matrix[i - 1][j] == true)
		result += func(i - 1, j);

	if (j - 1 >= 0 && matrix[i][j - 1] == true)
		result += func(i, j - 1);

	return ++result;
}

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

	int i, j;
	ll tmax;
	char buffer[10100];

	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;
				tmax = func(i, j);

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

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

	return 0;
}

