#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int r[100000][10]; set cur[10]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; REP (i, n) REP (j, m) cin >> r[i][j]; REP (i, n) { set winner; REP (j, m) { if (cur[j].empty()) cur[j].insert(i); else { int best = r[*cur[j].begin()][j]; if (r[i][j] == best) { cur[j].insert(i); } else if (r[i][j] > best) { cur[j].clear(); cur[j].insert(i); } } winner.insert(cur[j].begin(), cur[j].end()); } cout << winner.size() << endl; } return 0; }