#include <stdio.h>
//#include <conio.h>

#define UP [y-1][x]
#define DOWN [y+1][x]
#define LEFT [y][x-1]
#define RIGHT [y][x+1]
#define CURR [y][x]

int max = 0;
int count_for_sell = 0;
int count = 0;
int first_x = -1;
int first_y = -1;

char **arr;
int mX, mY;

void check_func(int y, int x);

int main()
{
	scanf("%d %d", &mY, &mX);

	arr = new char*[mY];
	
	for(int i = 0; i < mY; i++)
	{
		arr[i] = new char[mX];
		scanf("%s", arr[i]);
	}
	for(int i = 0; i < mY; i++)
	{
		for(int j = 0; j < mX; j++)
		{
			if(arr [i][j] == '1')
			{
				count_for_sell++;
				check_func(i, j);
			}
		}
	}
	printf("%d %d", count, max);
	//getch();
	delete [] arr;
	return 0;
}

void check_func(int y, int x)
{
	if(first_x == -1)
		first_x = x;
	if(first_y == -1)
		first_y = y;
	
	arr CURR = '3';

	if(x < mX-1)
	{
		if(arr RIGHT == '1')
		{
			count_for_sell++;
			check_func(y, x+1);
		}
	}
	if(y < mY-1)
	{
		if(arr DOWN == '1')
		{
			count_for_sell++;
			check_func(y+1, x);
		}
	}
	if(x > 0)
	{
		if(arr LEFT == '1')
		{
			count_for_sell++;
			check_func(y, x-1);
		}
	}
	if(y > 0)
	{
		if(arr UP == '1')
		{
			count_for_sell++;
			check_func(y-1, x);
		}
	}
	if(first_x == x && first_y == y)
	{
		count++;
		if(count_for_sell > max)
			max = count_for_sell;
		count_for_sell = 0;
		first_x = -1;
		first_y = -1;
	}
}