#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int main() {
  int a[N], f[N], n, m, ans = 1;
  double c;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d%lf", &a[i], &c);
    f[i] = 1;
  }
  if (m == 1) {
    cout << 0 << endl;
  } else {
    for (int i = 2; i <= n; i++) {
      int p = 0, max = 0;
      for (int j = 1; j <= i - 1; j++) {
        if ((f[j] > max) && (a[i] >= a[j])) {
          max = f[j];
          p = j;
        }
      }
      if (max) {
        f[i] = max + 1;
      }
      if (f[i] > ans) ans = f[i];
    }
    cout << n - ans << endl;
  }
}
