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