#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v;
long long dp[5001];
long long Min(int curidx) {
  if (curidx == n + 1) return 0;
  long long &t = dp[curidx];
  if (t != -1) return t;
  t = 99999999;
  for (int next = curidx + 1; next <= n + 1; ++next) {
    if (v[curidx] <= v[next]) t = min(t, Min(next) + next - curidx - 1);
  }
  return t;
}
int main() {
  ios::sync_with_stdio(false);
  memset(dp, -1, sizeof(dp));
  double f;
  cin >> n >> m;
  v.resize(n + 2);
  v[n + 1] = 99999999;
  v[0] = 0;
  for (int i = 1; i <= n; i++) cin >> v[i] >> f;
  cout << Min(0);
  return 0;
}
