#include <bits/stdc++.h>
using namespace std;
int a[5001] = {0};
int f[5001] = {0};
int max(int a, int b) {
  if (a < b) {
    return b;
  }
  return a;
}
int main() {
  int n, m;
  double dum;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> dum;
    f[i] = 0;
    for (int j = 0; j < i; j++) {
      if (a[j] <= a[i]) {
        f[i] = max(f[i], f[j] + 1);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (ans < f[i]) {
      ans = f[i];
    }
  }
  cout << n - ans << "\n";
  return 0;
}
