import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int m = Integer.parseInt(first[1]); HashSet[] maxIdxes = new HashSet[m]; int[] counts = new int[n]; for (int i = 0; i < m; i++) { maxIdxes[i] = new HashSet(); } int ans = 0; int[] maxValues = new int[m]; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { String[] line = br.readLine().split(" ", m); for (int j = 0; j < m; j++) { int x = Integer.parseInt(line[j]); if (maxValues[j] < x) { maxValues[j] = x; for (int y : maxIdxes[j]) { counts[y]--; if (counts[y] == 0) { ans--; } } maxIdxes[j].clear(); maxIdxes[j].add(i); counts[i]++; if (counts[i] == 1) { ans++; } } else if (maxValues[j] == x) { maxIdxes[j].add(i); counts[i]++; if (counts[i] == 1) { ans++; } } } sb.append(ans).append("\n"); } System.out.print(sb); } }