#include using namespace std; int main(){ int n, m; cin >> n >> m; vector v[m]; vector count(n, 0), maxi(m, 0); int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int k; cin >> k; if (maxi[j] == k) { count[i]++; if (count[i] == 1) ans++; v[j].push_back(i); } else if (maxi[j] < k) { maxi[j] = k; for (int u = 0; u < (int) v[j].size(); u++){ count[v[j][u]]--; if (count[v[j][u]] == 0) ans--; } v[j].clear(); count[i]++; if (count[i] == 1) ans++; v[j].push_back(i); } } cout << ans << endl; } return 0; }