n,m = map(int,input().split()) MAX = [0] *m k = [0]*n tama = [[] for i in range(m)] ans = 0 for i in range(n): a = list(map(int,input().split())) for j in range(m): if a[j] > MAX[j]: if len(tama[j]) != 0: for c in tama[j]: k[c] -= 1 if k[c] == 0: ans -= 1 tama[j] = [] tama[j].append(i) k[i] += 1 MAX[j] = a[j] elif a[j] == MAX[j]: k[i] += 1 tama[j].append(i) if k[i] >= 1: ans += 1 print(ans)