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]; for (int i = 0; i < m; i++) { maxIdxes[i] = new HashSet(); } int[] maxValues = new int[m]; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { String[] line = br.readLine().split(" ", m); HashSet count = new HashSet<>(); for (int j = 0; j < m; j++) { int x = Integer.parseInt(line[j]); if (maxValues[j] < x) { maxValues[j] = x; maxIdxes[j].clear(); maxIdxes[j].add(i); } else if (maxValues[j] == x) { maxIdxes[j].add(i); } count.addAll(maxIdxes[j]); } sb.append(count.size()).append("\n"); } System.out.print(sb); } }