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