#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void vrikodara(long long n = 12) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(n) << fixed;
}
long long lb = 100000;
long long solve_dp(long long n, long long idx, vector<long long> &v,
                   vector<long long> &dp) {
  if (idx == n) return 0;
  if (dp[idx] != -1) return dp[idx];
  long long &res = dp[idx];
  res = 0;
  for (long long i = idx + 1; i < n; i++) {
    if (v[i] >= v[idx]) res = max(res, solve_dp(n, i, v, dp));
  }
  return dp[idx] = res + 1;
}
long long longestIncreasingSubsequence(vector<long long> arr) {
  long long n = arr.size();
  vector<long long> dp(n + 5, -1);
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans = max(ans, solve_dp(n, i, arr, dp));
  }
  return ans;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    double a;
    cin >> v[i] >> a;
  }
  long long ans = n - longestIncreasingSubsequence(v);
  cout << ans;
}
int32_t main() {
  vrikodara();
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
