import java.io.PrintWriter;
import java.util.*;

public class nC {

	/*
	 * static class Scanner { StreamTokenizer in;
	 * 
	 * Scanner(InputStream is) { in = new StreamTokenizer(new
	 * InputStreamReader(is)); in.resetSyntax(); in.whitespaceChars(0, 32);
	 * in.wordChars(33, 255); }
	 * 
	 * String next() { try { in.nextToken(); if (in.ttype != in.TT_WORD) { throw
	 * new Error(); } return in.sval; } catch (IOException e) { throw new
	 * Error(e); } }
	 * 
	 * int nextInt() { return Integer.parseInt(next()); }
	 * 
	 * double nextDouble() { return Double.parseDouble(next()); } }
	 */

	Scanner in;
	PrintWriter out;

	class Point {
		int i;
		int j;
		int value;

		Point(int i, int j, int value) {
			this.i = i;
			this.j = j;
			this.value = value;
		}
	}

	void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		Point a[][] = new Point[n][m];
		for (int i = 0; i < n; i++) {
			String s = in.next();
			for (int j = 0; j < s.length(); j++) {
				if (s.charAt(j) == '0') {
					a[i][j] = new Point(i, j, 0);
				} else if (s.charAt(j) == '1') {
					a[i][j] = new Point(i, j, 1);
				} else {
					throw new Error();
				}
			}
		}
		boolean used[][] = new boolean[n][m];
		int col = 0;
		int max = 0;
		Queue<Point> q = new ArrayDeque<Point>();
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (!used[i][j] && a[i][j].value == 1) {
					col++;
					q.add(a[i][j]);
					used[i][j] = true;
					int sum = 1;
					while (!q.isEmpty()) {
						Point st = q.poll();
						for (int di = -1; di <= 1; di++) {
							for (int dj = -1; dj <= 1; dj++) {
								if (di * di + dj * dj == 1) {
									if (0 <= st.i + di && st.i + di < n
											&& 0 <= st.j + dj && st.j + dj < m) {
										if (!used[st.i + di][st.j + dj]
												&& a[st.i + di][st.j + dj].value == 1) {
											used[st.i + di][st.j + dj] = true;
											q.add(a[st.i + di][st.j + dj]);
											sum++;
										}
									}
								}
							}
						}
					}
					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();
	}

}
