public class Main {
    private static int pNums = 0;
    private static int qNums = 0;
    private static int qTmpSum = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] line1 = scanner.nextLine().split(",");
        int m = Integer.parseInt(line1[0]);
        int n = Integer.parseInt(line1[1]);
        int[][] grids = new int[m][n];
        for (int i = 0; i < m; i++) {
            String[] line2 = scanner.nextLine().split(",");
            for (int j = 0; j < n; j++) {
                grids[i][j] = Integer.parseInt(line2[j]);
            }
        }
        pNums = numIslands(grids);
        System.out.println(pNums + "," + qNums);
    }

    public static int numIslands(int[][] grid) {
        int m = grid.length;
        int n = grid[0].length;
        boolean[][] visited = new boolean[m][n];
        int result = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (grid[i][j] == 1 && !visited[i][j]) {
                    qTmpSum = 0;
                    numIslandsDFS(grid, visited, i, j);
                    result++;
                }
            }
        }
        return result;
    }

    private static void numIslandsDFS(int[][] grid, boolean[][] visited, int x, int y) {
        if (x < 0 || x >= grid.length)
            return;
        if (y < 0 || y >= grid[x].length)
            return;
        if (grid[x][y] != 1 || visited[x][y])
            return;
        visited[x][y] = true;
        qTmpSum++;
        if (qNums < qTmpSum)
            qNums = qTmpSum;
        numIslandsDFS(grid, visited, x - 1, y);
        numIslandsDFS(grid, visited, x - 1, y + 1);
        numIslandsDFS(grid, visited, x, y + 1);
        numIslandsDFS(grid, visited, x + 1, y + 1);
        numIslandsDFS(grid, visited, x + 1, y);
        numIslandsDFS(grid, visited, x + 1, y - 1);
        numIslandsDFS(grid, visited, x, y - 1);
        numIslandsDFS(grid, visited, x - 1, y - 1);
    }

}