#include <bits/stdc++.h>
using namespace std;
int n, m, sir[5005], lungmax;
struct ele {
  int t;
  double v;
} a[5005];
bool cmp(ele x, ele y) { return (x.v + 0.00000001 < y.v); }
int cauta(int st, int dr, int val) {
  if (st <= dr) {
    int mijl = (st + dr) / 2;
    if (sir[mijl] <= val)
      return cauta(mijl + 1, dr, val);
    else
      return cauta(st, mijl - 1, val);
  } else
    return st;
}
int main() {
  int i, poz;
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i].t >> a[i].v;
  sort(a + 1, a + n + 1, cmp);
  for (i = 1; i <= n; i++) {
    if (a[i].t >= sir[lungmax]) {
      lungmax++;
      sir[lungmax] = a[i].t;
    } else {
      poz = cauta(1, lungmax, a[i].t);
      sir[poz] = a[i].t;
    }
  }
  cout << n - lungmax;
  return 0;
}
