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