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

using namespace std;

typedef long long ll;

ll gcount, cmax, N, M;
string matrix[10100];

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

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

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

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

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

	return ++result;
}

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

	int i, j;
	ll tmax;

	scanf("%d %d", &M, &N);
	for (i = 0; i < M; ++i) {
		cin >> matrix[i];
	}

	for (i = 0; i < M; ++i) {
		for (j = 0; j < N; ++j) {
			if (matrix[i][j] == '1') {
				++gcount;
				tmax = func(i, j);

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

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

	return 0;
}

