#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int maxn = 3e5 + 123;
int n, m, a[maxn], dp[5050];
double z;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i] >> z, 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);
  int ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, dp[i]);
  cout << n - ans;
  return 0;
}
