sessional-exam

Mr. Aggarwal is a HOD of a department in a local university. After the Sessional exams he got his hands on a group's marks.

Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.

Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.

Your task is to find the number of successful students in the group.

Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.

Output
Print the single number — the number of successful students in the given group.

SAMPLE INPUT
3 3
223
232
112

SAMPLE OUTPUT
2

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
r=raw_input
z=list(map(r," "*int(r().split()[0])))
print(sum(any(i==max(j)for i,j in zip(s,list(zip(*z))))for s in z))


def main():
	a=list(map(int,input().split(" ")))
	n,m=a[0],a[1]
	b=[]
	for i in range(n):
		b.append(input())
	s=[]
	for j in range(m):
		c=[]
		for i in range(n):
			c.append(int(b[i][j]))
		#print len(c)
		m=max(c)
		for k in range(n):
			if c[k]==m :
				if k not in s:
					s.append(k)
	print(len(s))
if __name__=='__main__':
	main()