#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, k, l, n, m, ans = 0, temp = 0;
  cin >> n >> m;
  double dp;
  vector<long long> v;
  for (i = 1; i <= n; i++) {
    cin >> j >> dp;
    v.push_back(j);
  }
  vector<long long> trial;
  for (i = 0; i < n; i++) {
    if (i == 0) {
      trial.push_back(v[i]);
      ans++;
      continue;
    }
    if (v[i] >= trial.back()) {
      trial.push_back(v[i]);
      ans++;
      continue;
    }
    auto pos = upper_bound(trial.begin(), trial.end(), v[i]);
    long long dis = distance(trial.begin(), pos);
    trial[dis] = v[i];
  }
  cout << (n - ans) << endl;
  return 0;
}
