#include <bits/stdc++.h>
using namespace std;
const int siz = 5009;
int N, M, ar[siz];
int main() {
  while (cin >> N >> M) {
    int br[siz];
    for (int i = 0, _n = N; i < _n; i++) {
      int a;
      double s;
      cin >> ar[i] >> s;
    }
    int ret = 0;
    for (int i = 0, _n = N; i < _n; i++) {
      br[i] = 1;
      for (int j = i - 1; j >= 0; j--) {
        if (ar[j] <= ar[i]) br[i] = max(br[i], br[j] + 1);
      }
      ret = max(ret, br[i]);
    }
    cout << N - ret << endl;
  }
  return 0;
}
