from collections import defaultdict from sys import stdin, stdout input = lambda: stdin.readline().rstrip() write = stdout.write def main(): N, M = map(int, input().split()) R = stdin.read().splitlines() winner = [[] for _ in [0] * M] point = [0] * M player = defaultdict(int) for i, n in enumerate(R): m = list(map(int, n.split())) for j in range(M): if m[j] > point[j]: for k in winner[j]: player[k] -= 1 if not player[k]: player.pop(k) player[i] += 1 point[j] = m[j] winner[j] = [i] elif m[j] == point[j]: winner[j].append(i) player[i] += 1 print(len(player)) main()