import java.io.PrintWriter;
import java.util.Scanner;

public class nC {

	Scanner in;
	PrintWriter out;
	int sum = 0;

	void dfs(byte a[][], int x, int y, boolean used[][], int n, int m) {
		used[x][y] = true;
		for (int dx = -1; dx <= 1; dx++) {
			for (int dy = -1; dy <= 1; dy++) {
				if (dx * dx + dy * dy == 1) {
					if (0 <= x + dx && x + dx < n && 0 <= y + dy && y + dy < m) {
						if (!used[x + dx][y + dy] && a[x + dx][y + dy] == 1) {
							sum++;
							dfs(a, x + dx, y + dy, used, n, m);
						}
					}
				}
			}
		}
	}

	void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		in.nextLine();
		byte a[][] = new byte[n][m];
		for (int i = 0; i < n; i++) {
			String s = in.nextLine();
			for (int j = 0; j < s.length(); j++) {
				a[i][j] = (byte) (s.charAt(j) - '0');
			}
		}
		boolean used[][] = new boolean[n][m];
		int col = 0;
		int max = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (!used[i][j] && a[i][j] == 1) {
					col++;
					sum = 1;
					dfs(a, i, j, used, n, m);
					max = Math.max(max, sum);
				}
			}
		}
		out.println(col + " " + max);
	}

	void run() {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		new nC().run();
	}

}
