N, M = map(int, input().split()) m = [0]*M n = [[] for _ in range(M)] cnt = [0]*N res = 0 for i in range(N): R = list(map(int, input().split())) for j in range(M): if m[j] < R[j]: m[j] = R[j] for nn in n[j]: if cnt[nn] == 1: cnt[nn] = 0 res -= 1 else: cnt[nn] -= 1 n[j] = [] if m[j] == R[j]: if cnt[i] == 0: cnt[i] = 1 res += 1 else: cnt[i] += 1 n[j].append(i) print(res)