#include <bits/stdc++.h>
using namespace std;
int arr[5005], f[5005];
int main() {
  int n, m, maxi = 1;
  scanf("%d %d", &n, &m);
  float x;
  for (int i = 0; i < n; i++) {
    scanf("%d %f", &arr[i], &x);
    f[i] = 1;
  }
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= 0; j--) {
      if (arr[i] >= arr[j] && f[i] <= f[j]) f[i] = 1 + f[j];
    }
    if (f[i] > maxi) maxi = f[i];
  }
  printf("%d\n", n - maxi);
  return 0;
}
