#include <bits/stdc++.h>
using namespace std;
const double ee = 0.000001;
int main() {
  int n, m;
  cin >> n >> m;
  int pl[n];
  double cc[n];
  for (int i = 0; i < n; i++) cin >> pl[i] >> cc[i];
  vector<int> dp(n, 1);
  dp[0] = 1;
  for (int i = 1; i < n; i++)
    for (int j = 0; j < i; j++)
      if (pl[j] <= pl[i] && dp[i] < dp[j] + 1) dp[i] = dp[j] + 1;
  sort(dp.begin(), dp.end());
  cout << n - dp[n - 1];
  return 0;
}
