#include #include using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n, m, r; cin >> n >> m; vector r_max(m, 0), wins(n, 0); vector > id(m); int ans = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> r; if (r > r_max[j]) { r_max[j] = r; ++wins[i]; for (int k = 0; k < id[j].size(); ++k) { --wins[id[j][k]]; if (wins[id[j][k]] == 0) --ans; } id[j].clear(); id[j].shrink_to_fit(); id[j].emplace_back(i); } else if (r == r_max[j]) { ++wins[i]; id[j].emplace_back(i); } } if (wins[i] > 0) ++ans; cout << ans << endl; } return 0; }