#include <bits/stdc++.h>
using namespace std;
using namespace std;
struct my {
  int a;
  double b;
};
bool Cmp(my a, my b) { return a.b <= b.b; }
int main() {
  int n, m;
  cin >> n >> m;
  my mine[n];
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    double b;
    cin >> b;
    mine[i].a = a;
    mine[i].b = b;
  }
  sort(mine, mine + n, Cmp);
  int ord[n];
  for (int i = 0; i < n; ++i) {
    ord[i] = mine[i].a;
  }
  int dp[n];
  for (int i = 0; i < n; ++i) {
    dp[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i - 1; j >= 0; j--) {
      if (ord[j] <= ord[i]) {
        dp[i] = max(dp[j] + 1, dp[i]);
      }
    }
  }
  cout << n - *max_element(dp, dp + n) << endl;
  return 0;
}
