#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  double b[n];
  int dp[n], a[n];
  for (long long i = 1; i <= (long long)n; i++) {
    cin >> a[i] >> b[i];
    dp[i] = 1;
  }
  int ans = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = i - 1; j >= 1; j--) {
      if (a[i] >= a[j]) dp[i] = max(dp[i], dp[j] + 1);
    }
    ans = max(ans, dp[i]);
  }
  cout << n - ans << endl;
}
