import sys readline = sys.stdin.readline N, M = map(int, readline().split()) maxv = list(map(int, readline().split())) cnt = [0] * N cnt[0] = M ans = 1 L = [[0] for i in range(10)] print(1) for i in range(1, N): now = list(map(int, readline().split())) for j in range(M): if now[j] > maxv[j]: maxv[j] = now[j] while L[j]: v = L[j].pop() cnt[v] -= 1 if cnt[v] == 0: ans -= 1 cnt[i] += 1 if cnt[i] == 1: ans += 1 L[j].append(i) elif now[j] == maxv[j]: L[j].append(i) cnt[i] += 1 if cnt[i] == 1: ans += 1 print(ans)