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