#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
int n, m, dp[N], arr[N];
double brr[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> arr[i] >> brr[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    dp[i] = 1;
    for (int j = 0; j < i; j++)
      if (arr[i] >= arr[j]) dp[i] = max(dp[i], dp[j] + 1);
    ans = max(dp[i], ans);
  }
  cout << n - ans << endl;
  return 0;
}
