#include <bits/stdc++.h>
using namespace std;
int n, m, a[5010], d[5010], r;
int c[5010];
int xmin[5010];
void nhap() {
  double z;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i] >> z;
}
int tim(int x) {
  int l = 0;
  int r = n + 1;
  while (r - l > 1) {
    int tb = (l + r) / 2;
    if (xmin[tb] > x)
      r = tb;
    else
      l = tb;
  }
  return l;
}
void xuli() {
  for (int i = 1; i <= n + 1; i++) xmin[i] = 1000000007;
  for (int i = 1; i <= n; i++) {
    int vitri = tim(a[i]);
    xmin[vitri + 1] = a[i];
  }
  for (int i = 1; i <= n + 1; i++)
    if (xmin[i] == 1000000007) {
      r = i - 1;
      break;
    }
  cout << n - r;
}
int main() {
  nhap();
  xuli();
}
