#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  multiset<int> S;
  for (int i = 0; i < n; i++) {
    int x;
    double y;
    scanf("%d%lf", &x, &y);
    auto it = S.upper_bound(x);
    if (it != S.end()) S.erase(it);
    S.insert(x);
  }
  printf("%d\n", n - S.size());
}
