public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String l = br.readLine();
		int N = Integer.parseInt(l.split(" ")[0]);
		int M = Integer.parseInt(l.split(" ")[1]);
		String[] teams = new String[N];
		for (int i = 0; i < N; i++) {
			String line = br.readLine();
			teams[i] = line;
		}
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		int maxTopic = Integer.MIN_VALUE;
		for (int i = 0; i < N; i++) {
			String team1 = teams[i];
			for (int j = i + 1; j < N; j++) {
				int count = 0;
				String team2 = teams[j];
				for (int k = 0; k < M; k++) {
					String s = String.valueOf(team1.charAt(k));
					String s2 = String.valueOf(team2.charAt(k));
					if (s.equals("1") || s2.equals("1")) {
						count++;
					}
				}
				if (count > maxTopic || count == maxTopic) {
					maxTopic = count;
					if (!map.containsKey(maxTopic)) {
						map.put(maxTopic, 1);
					} else {
						map.put(maxTopic, map.get(maxTopic) + 1);
					}
				}
			}
		}
		 System.out.println(maxTopic);
		System.out.println(map.get(maxTopic));
		br.close();
	}