#include <bits/stdc++.h>
using namespace std;
void read(int a = 0) {
  freopen("in", "r", stdin);
  if (a) freopen("out", "w", stdout);
}
int n;
int a[100009];
int dp[5009][5009];
int ans(int ind, int last) {
  if (ind == n) return 0;
  if (dp[ind][last] == -1) {
    int tmp = 1 + ans(ind + 1, last);
    if (a[ind] >= last) tmp = min(tmp, ans(ind + 1, a[ind]));
    dp[ind][last] = tmp;
  }
  return dp[ind][last];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  memset(dp, -1, sizeof(dp));
  cin >> n;
  int m;
  cin >> m;
  double d;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> d;
  }
  cout << ans(0, 0);
}
