import java.util.Scanner; public class worldCup { static int nums=0; public static void main(String[] args){ Scanner sc=new Scanner(System.in); String[] str=sc.next().split(","); int m=Integer.valueOf(str[0]); int n=Integer.valueOf(str[1]); int[][] a=new int[m][n]; for (int i=0;i<m;i++){ String[] str1=sc.next().split(","); for (int j=0;j<n;j++){ a[i][j]=Integer.valueOf(str1[j]); } } int[][] vis=new int[m][n]; int max_nums=0;int P=0; for (int i=0;i<m;i++){ for (int j=0;j<n;j++){ if (a[i][j]==1 && vis[i][j]==0){ P+=1;nums=1; dfs(a,vis,i,j); if (nums>max_nums) max_nums=nums; } } } //max_nums=max_nums==0?0:max_nums-1; System.out.println(P+","+max_nums); } private static void dfs(int[][] a,int[][] vis,int curr_i,int curr_j){ System.out.println(nums); vis[curr_i][curr_j]=1; if (a[curr_i][curr_j]==0){ return; } int[][] dir={{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{-1,1},{1,-1},{1,1}}; for (int i=0;i<dir.length;i++){ int x=curr_i+dir[i][0]; int y=curr_j+dir[i][1]; if (x>=a.length || x<0 || y<0 ||y>=a[0].length) continue; if (a[x][y]==1 && vis[x][y]==0){ nums+=1; vis[x][y]=1; dfs(a,vis,x,y); } } } }