#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 5 + 10, INF = 1e9 + 10;
int dp[MAXN], a[MAXN];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    double d;
    cin >> a[i] >> d;
    dp[i] = 1;
  }
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  int mx = 0;
  for (int i = 1; i < n; i++)
    for (int j = 0; j < i; j++) {
      if (a[i] >= a[j]) dp[i] = max(dp[i], dp[j] + 1);
      mx = max(mx, dp[i]);
    }
  cout << n - mx << endl;
  return 0;
}
