#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define FORR(i, m, n) for (ll i = m; i >= n; i--) #define REPO(i, n) for (ll i = 1; i <= n; i++) #define ll long long #define INF (ll)1 << 60 #define MINF (-1 * INF) #define ALL(n) n.begin(), n.end() #define MOD 1000000007 #define P pair ll n, m, ans; ll cnt[210000], mx[210000]; vector s[210000]; int main(){ cin >> n >> m; vector b(n), c(n); REP(i, n){ cin >> b[i] >> c[i]; s[c[i]].push_back(b[i]); } REP(i, 210000){ map mm; ll nm = 0; REP(j, s[i].size()){ mm[s[i][j]]++; nm = max(nm, mm[s[i][j]]); } ans += s[i].size() - nm; } cout << ans << endl; }