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