#include <bits/stdc++.h>
using namespace std;
const int N = 5001;
int n, m, a[N], dp[2][N];
int main() {
  cin >> n >> m;
  double dummy;
  for (int i = 0; i < n; i++) cin >> a[i] >> dummy;
  for (int j = 0; j <= m; j++) dp[n % 2][j] = 0;
  int ans = N;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m; j >= 0; j--) {
      dp[i % 2][j] = 1 + dp[(i + 1) % 2][j];
      if (a[i] >= j) dp[i % 2][j] = min(dp[i % 2][j], dp[(i + 1) % 2][a[i]]);
      if (i == 0) ans = min(ans, dp[i % 2][j]);
    }
  }
  cout << ans;
  return 0;
}
