#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[5010];
float b[5010];
int main() {
  int dp[5010];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d%f", &a[i], &b[i]);
  }
  for (int i = 0; i < n; i++) {
    dp[i] = 1;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (a[i] >= a[j] && dp[j] + 1 >= dp[i]) {
        dp[i] = dp[j] + 1;
      }
    }
  }
  int t;
  sort(dp, dp + n);
  printf("%d", n - dp[n - 1]);
  return 0;
}
