n,m = map(int,input().split()) val = [0]*m cnt = [0]*n kouho = [[] for _ in range(m)] ans = 0 for idx in range(n): *r, = map(int,input().split()) for j,rj in enumerate(r): if val[j] < rj: val[j] = rj cnt[idx] += 1 for i in kouho[j]: cnt[i] -= 1 if cnt[i] == 0: ans -= 1 kouho[j] = [idx] elif val[j] == rj: cnt[idx] += 1 kouho[j].append(idx) if cnt[idx]: ans += 1 print(ans)