#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
int n, m, arr[5100], dp[5100];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    double a;
    cin >> arr[i] >> a;
  }
  dp[1] = arr[1];
  for (int i = 2; i <= n; i++) dp[i] = mod;
  int mx = 1;
  for (int i = 2; i <= n; i++) {
    int l = 0, r = i;
    while (l < r) {
      int mid = (l + r + 1) / 2;
      if (dp[mid] <= arr[i])
        l = mid;
      else
        r = mid - 1;
    }
    dp[l + 1] = min(dp[l + 1], arr[i]);
    mx = max(mx, l + 1);
  }
  cout << n - mx << "\n";
  return 0;
}
