#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int a[5001], b[5001], n, m, ans = 0;
  double x;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i] >> x;
  for (int i = 0; i < n; i++) b[i] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++)
      if (a[j] <= a[i]) b[i] = max(b[i], b[j] + 1);
  for (int i = 0; i < n; i++) ans = max(ans, b[i]);
  cout << n - ans << endl;
  return 0;
}
