#include <bits/stdc++.h>
int main(void) {
  int i, j, n, m, *dp, *t, maxi = 0;
  scanf("%d %d\n", &n, &m);
  dp = (int*)malloc(sizeof(int) * n);
  t = (int*)malloc(sizeof(int) * n);
  if (!dp || !t) return 1;
  for (i = 0; i < n; i++) {
    scanf("%d %*f\n", &t[i]);
    dp[i] = 1;
    for (j = 0; j < i; j++)
      if (t[i] >= t[j]) dp[i] = (dp[i] > dp[j] + 1) ? dp[i] : dp[j] + 1;
    maxi = (maxi >= dp[i]) ? maxi : dp[i];
  }
  printf("%d\n", n - maxi);
  free(t);
  free(dp);
  return 0;
}
