n,m = map(int,input().split()) max_status = [0]*m candidate = [0]*m count = 0 top_change = False top_tie = False for i in range(n): status = list(map(int,input().split())) for j in range(m): if status[j]>max_status[j]: max_status[j] = status[j] candidate[j] = [i+1] top_change = True elif status[j]==max_status[j]: candidate[j] += [i+1] top_tie = True if top_change: ans = [] for j in candidate: ans += j count = len(set(ans)) top_change = False top_tie = False elif top_tie: count += 1 top_tie = False print(count)