#include <bits/stdc++.h>
using namespace std;
int n, m, s[5000], dp[5001] = {};
int main() {
  double tx;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d%lf", s + i, &tx);
  for (int i = 1; i <= n; ++i) {
    for (int j = s[i - 1]; j >= 1; --j)
      dp[s[i - 1]] = max(dp[s[i - 1]], dp[j] + 1);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans = max(ans, dp[i]);
  printf("%d\n", n - ans);
  return 0;
}
