#include <bits/stdc++.h>
using namespace std;
int n, ms, type[5005], dp[5005];
int main() {
  scanf("%d %d", &n, &ms);
  for (int i = 1; i <= n; i++) {
    double x;
    scanf("%d %lf", type + i, &x);
  }
  for (int i = 1; i <= n; i++) {
    int j = type[i];
    for (int k = j; k >= 1; k--) {
      dp[j] = max(dp[j], 1 + dp[k]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dp[i]);
  }
  printf("%d\n", n - ans);
}
