#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, mod = 9901;
int d[maxn];
vector<pair<double, int> > v;
int main() {
  ios::sync_with_stdio(0);
  int n, b, ans = 0, a, m;
  double c;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> b >> c;
    v.push_back(make_pair(c, b));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    b = v[i].second;
    for (int j = 0; j < i; j++) {
      a = v[j].second;
      if (b >= a) d[i] = max(d[i], d[j] + 1);
    }
  }
  for (int i = 0; i < n; i++) ans = max(ans, d[i]);
  cout << n - ans - 1 << endl;
  return 0;
}
