#include <bits/stdc++.h>
using namespace std;
const unsigned long long P = 239017, MaxN = 2100000, INF = 100000000;
int n, m, dp[5001], a[5001];
int main() {
  scanf("%d%d", &n, &m);
  double t;
  for (int i = 0; i < n; ++i) scanf("%d%lf", &a[i], &t);
  dp[0] = 1;
  int mx = 1;
  for (int i = 1; i < n; ++i) {
    dp[i] = 1;
    for (int j = 0; j < i; ++j) {
      if (a[j] <= a[i]) dp[i] = max(dp[i], dp[j] + 1);
    }
    mx = max(mx, dp[i]);
  }
  printf("%d", n - mx);
  return 0;
}
