#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, mx = 0, c = 0;
  cin >> n >> m;
  long double y;
  vector<pair<long double, int> > v;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    v.push_back(make_pair(y, x));
  }
  sort(v.begin(), v.end());
  vector<int> d(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (v[i].second >= v[j].second) d[i] = max(d[i], d[j]);
    }
    d[i]++;
    mx = max(d[i], mx);
  }
  cout << n - mx;
}
