#include <bits/stdc++.h>
using namespace std;
int dp[3000001];
inline int read();
int main() {
  int n, m;
  cin >> n >> m;
  int cnt = 0;
  int x, pos;
  double y;
  for (register int i = 1; i <= n; i++) {
    cin >> x >> y;
    if (x >= dp[cnt])
      dp[++cnt] = x;
    else
      dp[upper_bound(dp + 1, dp + cnt + 1, x) - dp] = x;
  }
  cout << n - cnt;
  return 0;
}
