#include <bits/stdc++.h>
using namespace std;
const double eps(1e-8);
int n, m;
int f[6000];
int ans;
int a[6000];
int main() {
  scanf("%d %d", &n, &m);
  double x;
  for (int i = (1); i <= (n); ++i) scanf("%d %lf", &a[i], &x);
  f[1] = 1;
  ans = 1;
  for (int i = (2); i <= (n); ++i) {
    f[i] = 1;
    for (int j = (1); j <= (i - 1); ++j)
      if (a[i] >= a[j]) f[i] = max(f[i], f[j] + 1);
    ans = max(ans, f[i]);
  }
  cout << n - ans << endl;
}
