N, M = list(map(int, input().split())) R = [] m_t = [-float('inf') for i in range(3)] for i in range(N): l = list(map(int, input().split())) for j in range(M): m_t[j] = max([m_t[j],l[j]]) R.append(l) s = set() for j in range(M): for k in range(i+1): if R[k][j]==m_t[j]: s.add(k) print(len(s))