import java.util.*; import java.io.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String nm = br.readLine(); String[] arr = nm.split(" "); int m = Integer.valueOf(arr[0]); int n = Integer.valueOf(arr[1]); char[][] num = new char[m][n]; for (int i = 0; i < m; i++) { String str = br.readLine(); for (int j = 0; j < n; j++) { num[i][j] = str.charAt(j); } } Map<String, Integer> dict = new HashMap<>(); for (int i = 0; i < n; i++) { StringBuilder sbr = new StringBuilder(); for (int j = 0; j < m; j++) { sbr.append(num[j][i]); } String key = sbr.toString(); if (!dict.containsKey(key)) { dict.put(key, 1); } else { dict.put(key, dict.get(key) + 1); } } Integer max = dict.values().stream().max((a, b) -> a - b).get(); System.out.println(max); } }