n,m=map(int,input().split()) s=[[] for i in range(m)] maxnum=[0]*m ncnt=[0]*n now=0 for i in range(n): a=list(map(int,input().split())) for j in range(m): if a[j] == maxnum[j]: s[j].append(i) if ncnt[i] == 0: now+=1 ncnt[i] += 1 elif a[j] > maxnum[j]: for k in range(len(s[j])): t=s[j].pop() ncnt[t] -= 1 if ncnt[t] == 0: now -= 1 s[j].append(i) if ncnt[i] == 0: now+=1 ncnt[i] += 1 maxnum[j] = a[j] print(now)