Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.

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.
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.
3 3
223
232
112
2
3 5
91728
11828
11111
3
2 2
48
27
1
2 1
4
6
1
1 2
57
1
1 1
5
1
3 4
2553
6856
5133
2
8 7
6264676
7854895
3244128
2465944
8958761
1378945
3859353
6615285
6
9 8
61531121
43529859
18841327
88683622
98995641
62741632
57441743
49396792
63381994
4
10 20
26855662887514171367
48525577498621511535
47683778377545341138
47331616748732562762
44876938191354974293
24577238399664382695
42724955594463126746
79187344479926159359
48349683283914388185
82157191115518781898
9
20 15
471187383859588
652657222494199
245695867594992
726154672861295
614617827782772
862889444974692
373977167653235
645434268565473
785993468314573
722176861496755
518276853323939
723712762593348
728935312568886
373898548522463
769777587165681
247592995114377
182375946483965
497496542536127
988239919677856
859844339819143
18
13 9
514562255
322655246
135162979
733845982
473117129
513967187
965649829
799122777
661249521
298618978
659352422
747778378
723261619
11
75 1
2
3
8
3
2
1
3
1
5
1
5
4
8
8
4
2
5
1
7
6
3
2
2
3
5
5
2
4
7
7
9
2
9
5
1
4
9
5
2
4
6
6
3
3
9
3
3
2
3
4
2
6
9
1
1
1
1
7
2
3
2
9
7
4
9
1
7
5
6
8
3
4
3
4
6
7
92 3
418
665
861
766
529
416
476
676
561
995
415
185
291
176
776
631
556
488
118
188
437
496
466
131
914
118
766
365
113
897
386
639
276
946
759
169
494
837
338
351
783
311
261
862
598
132
246
982
575
364
615
347
374
368
523
132
774
161
552
492
598
474
639
681
635
342
516
483
141
197
571
336
175
596
481
327
841
133
142
146
246
396
287
582
556
996
479
814
497
363
963
162
23
100 1
1
6
9
1
1
5
5
4
6
9
6
1
7
8
7
3
8
8
7
6
2
1
5
8
7
3
5
4
9
7
1
2
4
1
6
5
1
3
9
4
5
8
1
2
1
9
7
3
7
1
2
2
2
2
3
9
7
2
4
7
1
6
8
1
5
6
1
1
2
9
7
4
9
1
9
4
1
3
5
2
4
4
6
5
1
4
5
8
4
7
6
5
6
9
5
8
1
5
1
6
10
100 2
71
87
99
47
22
87
49
73
21
12
77
43
18
41
78
62
61
16
64
89
81
54
53
92
93
94
68
93
15
68
42
93
28
19
86
16
97
17
11
43
72
76
54
95
58
53
48
45
85
85
74
21
44
51
89
75
76
17
38
62
81
22
66
59
89
85
91
87
12
97
52
87
43
89
51
58
57
98
78
68
82
41
87
29
75
72
48
14
35
71
74
91
66
67
42
98
52
54
22
41
21
5 20
11111111111111111111
11111111111111111111
11111111111111111111
99999999999999999999
11111111111111111119
2
3 3
111
111
999
1
3 3
119
181
711
3
15 5
91728
11828
11111
91728
11828
11111
91728
11828
11111
91728
11828
11111
91728
11828
11111
15
2 20
22222222222222222222
11111111111111111111
1
3 3
233
222
111
2
4 15
222222222222222
111111111111119
111111111111119
111111111111111
3
4 1
1
9
9
9
3
3 3
123
321
132
3
3 3
113
332
322
3
2 100
2222222222222222222222222222222222222222222222222222222222222222222222221222222222222222222222222222
1111111111111111111111111111111111111111111111111111111111111111111111119111111111111111111111111111
2
3 3
321
231
123
3
2 100
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
1
3 3
221
111
111
3
n, m = [int(i) for i in input().split()]
grades = []
res = 0
for i in range(n):
    g = input()
    sub = []
    for j in g:
        sub.append(int(j))
    grades.append(sub)

pos = 0
while pos < len(grades[0]):
    subj = []
    for student in grades:
        subj.append(student[pos])
    sub = []
    best = min(subj)
    subj.remove(best)
    for num in subj:
        if best == num:
            break
    else:
        res += 1
    pos += 1

print(res)
