#include <bits/stdc++.h>
using namespace std;
const int Nmax = 5000;
int a[Nmax], sub[Nmax];
int main() {
  int n, m;
  double useless;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> useless;
    sub[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[j] >= a[i]) {
        sub[j] = max(sub[j], sub[i] + 1);
      }
    }
  }
  sort(sub, sub + n);
  cout << n - sub[n - 1];
  return 0;
}
