#include <bits/stdc++.h>
using namespace std;
int dp[5100];
int main() {
  int n, m;
  int s[5100];
  cin >> n >> m;
  double tmp;
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> tmp;
  }
  int ans = 1;
  memset(dp, 0, n);
  for (int i = 0; i < n; i++) {
    int max = 0;
    for (int j = 0; j < i; j++) {
      if (s[j] <= s[i]) {
        if (dp[j] > max) {
          max = dp[j];
        }
      }
    }
    dp[i] += max + 1;
    if (dp[i] > ans) ans = dp[i];
  }
  cout << n - ans << endl;
}
