# -*- coding: utf-8 -*- N, M = map(int, input().split()) A = [0]*M B = [[] for _ in range(M)] for n in range(N): tmp = set() for m, r in enumerate(map(int, input().split())): if A[m] < r: B[m] = [n] A[m] = r elif A[m] == r: B[m].append(n) tmp.update(B[m]) print(len(tmp))