#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
template <class T>
inline void read(T& x, T& y) {
  read(x);
  read(y);
}
template <class T>
inline void read(T& x, T& y, T& z) {
  read(x);
  read(y);
  read(z);
}
inline char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
int n, m, i, j, k, l, p;
int c[5010];
long double x[5010];
int f[5010];
int main() {
  read(n, m);
  for (i = 1; i <= n; i++) cin >> c[i] >> x[i];
  int ans = 0;
  for (i = 1; i <= n; i++) {
    f[i] = 1;
    for (j = 1; j <= i - 1; j++)
      if (c[j] <= c[i]) f[i] = max(f[i], f[j] + 1);
    ans = max(ans, f[i]);
  }
  cout << n - ans << endl;
  scanf("\n");
  return 0;
}
