#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, a[5005], dp[5005], rs = 1;
double aux;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (i = 1; i <= n; ++i) cin >> a[i] >> aux, dp[i] = 1;
  for (i = 1; i <= n; ++i)
    for (j = 1; j < i; ++j)
      if (a[j] <= a[i]) dp[i] = max(dp[i], dp[j] + 1), rs = max(rs, dp[i]);
  cout << n - rs << '\n';
  return 0;
}
