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

public class Main implements Runnable {

	static class Point {
		int i;
		int j;

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

	Scanner in;
	PrintWriter out;

	void solve() {
		int nRows = in.nextInt();
		int nCols = in.nextInt();
		in.nextLine();
		int field[][] = new int[1 + nRows + 1][1 + nCols + 1];
		for (int i = 1; i <= nRows; i++) {
			String line = in.nextLine();
			for (int j = 1; j <= nCols; j++) {
				if (line.charAt(j - 1) == '1') {
					field[i][j] = 1;
				}
			}
		}
		int totalCnt = 0;
		int maxSize = 0;
		for (int i = 1; i <= nRows; i++) {
			for (int j = 1; j <= nCols; j++) {
				if (field[i][j] == 1) {
					totalCnt++;
					curSize = 0;
					bfs(field, i, j);
					if (curSize > maxSize) {
						maxSize = curSize;
					}
				}
			}
		}
		out.print(totalCnt + " " + maxSize);
	}

	int curSize = 0;

	private void bfs(int[][] field, int i, int j) {
		Queue<Point> queue = new LinkedList<Point>();
		queue.add(new Point(i, j));
		while (!queue.isEmpty()) {
			Point cur = queue.poll();
			field[cur.i][cur.j] = 2;
			curSize++;
			for (int di = -1; di <= 1; di++) {
				for (int dj = -1; dj <= 1; dj++) {
					if (((di == 1 || di == -1) && dj == 0)
							|| ((dj == 1 || dj == -1) && di == 0)) {
						if (field[cur.i + di][cur.j + dj] == 1) {
							field[cur.i + di][cur.j + dj] = 2;
							queue.add(new Point(cur.i + di, cur.j + dj));

						}
					}
				}
			}

		}
	}

	public void run() {
		// gen();

		in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		try {
			solve();
		} finally {
			out.close();
		}
	}

	void gen() {
		try {
			out = new PrintWriter("output.txt");
			int nRows = 10;
			int nCols = 100000;
			out.println(nRows + " " + nCols);
			for (int i = 0; i < nRows; i++) {
				for (int j = 0; j < nCols; j++) {
					out.print(1);
				}
				out.println();
			}
		} catch (Exception e) {
			// TODO: handle exception
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) {

		try {
			new Thread(null, new Main(), "Main", 64 * 1024 * 1000L).start();
		} catch (Throwable e) {
			throw new Error();
		}
	}

}
