#include <bits/stdc++.h>
using namespace std;
int n, m, a[5005], f[5005];
int main() {
  double gar;
  scanf(" %d %d ", &n, &m);
  for (int i = 0, _n = (n); i < _n; i++) scanf(" %d %lf ", &a[i], &gar);
  int res = 0;
  for (int i = 0, _n = (n); i < _n; i++) {
    f[i] = 1;
    for (int j = 0, _n = (i); j < _n; j++)
      if (a[j] <= a[i]) f[i] = max(f[i], f[j] + 1);
    res = max(res, f[i]);
  }
  printf("%d\n", n - res);
  return 0;
}
