#include <bits/stdc++.h>
using namespace std;
const int maxn = 111111;
int dp[maxn];
int main() {
  int n, m;
  double t;
  while (cin >> n >> m) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> t;
    fill(dp, dp + n + 1, (1 << 30));
    dp[0] = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int p = upper_bound(dp, dp + n + 1, a[i]) - dp;
      dp[p] = a[i];
      ans = max(ans, p);
    }
    cout << n - ans << endl;
  }
  return 0;
}
