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

public class Main implements Runnable {

	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;
					dfs(field, i, j);
					if (curSize > maxSize) {
						maxSize = curSize;
					}
				}
			}
		}
		out.print(totalCnt + " " + maxSize);
	}

	int curSize = 0;

	private void dfs(int[][] field, int i, int j) {
		field[i][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[i + di][j + dj] == 1) {
						dfs(field, i + di, j + dj);
					}
				}
			}
		}
	}

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

	public static void main(String args[]) {
		new Thread(null, new Main(), "Main", 64 * 1024 * 1000L).start();

	}

}
