#include <bits/stdc++.h>
using namespace std;
int arr[5005], dp[5005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    double y;
    cin >> y;
  }
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    dp[i] = 1;
    for (int j = i - 1; j >= 0; --j) {
      if (arr[j] <= arr[i]) {
        dp[i] = max(dp[i], dp[j] + 1);
        ans = max(ans, dp[i]);
      }
    }
  }
  cout << n - ans << endl;
}
