import sys input = sys.stdin.buffer.readline N, M = map(int, input().split()) max_param = [0] * M winners = [None] * M for i in range(1, N + 1): R = map(int, input().split()) for j, r in enumerate(R): if max_param[j] < r: winners[j] = [i] max_param[j] = r elif max_param[j] == r: winners[j].append(i) winners_set = set() for w in winners: winners_set.update(w) print(len(winners_set))