#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, m, second[6000], d[6000];
double x;
int ans;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> second[i] >> x;
  }
  for (int i = 1; i <= n; ++i) {
    d[i] = 1;
    for (int j = 1; j < i; ++j) {
      if (second[i] >= second[j]) {
        d[i] = max(d[i], d[j] + 1);
      }
    }
  }
  int ans = -inf;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, d[i]);
  }
  cout << n - ans << endl;
}
