#include <bits/stdc++.h>
using namespace std;
int n, m, a[5010], d[5010], r;
void nhap() {
  double z;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i] >> z;
}
void xuli() {
  for (int i = 1; i <= n; i++) {
    d[i] = 0;
    for (int j = 0; j <= i - 1; j++)
      if (a[i] >= a[j]) d[i] = max(d[j] + 1, d[i]);
    r = max(r, d[i]);
  }
  cout << n - r;
}
int main() {
  nhap();
  xuli();
}
