#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]; map winner; REP (i, n) { REP (j, m) { if (cur[j].empty()) { cur[j].insert(i); ++winner[i]; } else { int best = r[*cur[j].begin()][j]; if (r[i][j] == best) { cur[j].insert(i); ++winner[i]; } else if (r[i][j] > best) { for (int x: cur[j]) { if (!--winner[x]) winner.erase(x); } cur[j].clear(); cur[j].insert(i); ++winner[i]; } } } cout << winner.size() << endl; } return 0; }