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