#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int a[5005], b[5005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    double tmp;
    scanf("%d%lf", &a[i], &tmp);
    b[i] = INF;
  }
  int mxlen = 1;
  for (int i = 1; i <= n; i++) {
    int id = upper_bound(b + 1, b + n + 1, a[i]) - b;
    mxlen = max(mxlen, id);
    b[id] = a[i];
  }
  cout << n - mxlen << endl;
  return 0;
}
