#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n + 1];
  int dp[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    double x;
    cin >> x;
  }
  dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    int r = 0;
    for (int j = 1; j < i; j++)
      if (a[i] >= a[j]) r = max(r, dp[j]);
    dp[i] = r + 1;
  }
  int t = dp[1];
  for (int i = 1; i <= n; i++) t = max(t, dp[i]);
  cout << n - t;
  return 0;
}
