from collections import defaultdict N, M = map(int, input().split()) d = defaultdict(set) m = [0]*M n = [set() for _ in range(M)] for i in range(N): R = list(map(int, input().split())) for j in range(M): if R[j] == m[j]: n[j].add(i) if R[j] > m[j]: n[j].clear() n[j].add(i) m[j] = R[j] res = set() for k in range(M): res |= n[k] print(len(res))