#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int a[N], dp[N];
int main() {
  int n, m, ans = 0;
  double t;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i] >> t;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++)
      if (a[j] <= a[i]) dp[i] = max(dp[j], dp[i]);
    dp[i]++;
  }
  for (int i = 0; i < n; i++) ans = max(dp[i], ans);
  cout << n - ans;
  return 0;
}
