#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
int dp[maxn][maxn], a[maxn], ans;
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    double fake;
    cin >> a[i] >> fake;
  }
  for (int i = 1; i <= n; i++) {
    for (int type = 1; type <= k; type++) dp[i][type] = dp[i - 1][type];
    for (int type = 1; type <= a[i]; type++)
      dp[i][a[i]] = max(dp[i][a[i]], dp[i - 1][type] + 1);
    ans = max(ans, dp[i][a[i]]);
  }
  cout << n - ans << endl;
  return 0;
}
