#include <bits/stdc++.h>
using namespace std;
struct name {
  int type;
  double dek;
};
bool tmp_dek(name A, name B) { return A.dek < B.dek; };
name a[6000];
int dp[6000];
int n, m, i, j, ans;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i].type >> a[i].dek;
  sort(a + 1, a + n + 1, tmp_dek);
  for (i = 1; i <= n; i++) {
    for (j = 0; j < i; j++)
      if (a[i].type >= a[j].type) dp[i] = max(dp[i], dp[j] + 1);
    ans = max(ans, dp[i]);
  }
  cout << n - ans << endl;
}
