#include <bits/stdc++.h>
using namespace std;
int spec[100003];
int dp[100003];
int arr[100003];
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  double tmp;
  for (int i = 0; i < n; i++) {
    cin >> arr[i] >> tmp;
  }
  for (int i = n - 1; i >= 0; i--) {
    dp[i] = 1;
    for (int j = i + 1; j < n; j++) {
      if (arr[i] <= arr[j]) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
  }
  int maxime = 0;
  for (int i = 0; i < n; i++) {
    maxime = max(maxime, dp[i]);
  }
  cout << n - maxime << '\n';
  return 0;
}
