#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
const long long N = 10010;
long long res[N];
long long dp[N];
int main() {
  long long n, m;
  cin >> n >> m;
  double a, b;
  for (long long i = 1; i <= n; ++i) {
    cin >> res[i] >> a;
  }
  long long maxm = -0x3f3f3f3f;
  for (long long i = 1; i <= n; ++i) {
    dp[i] = 1;
    long long opt = 0;
    for (long long j = 1; j < i; ++j) {
      if (res[i] >= res[j]) opt = max(dp[j], opt);
    }
    dp[i] = opt + 1;
    maxm = max(maxm, dp[i]);
  }
  cout << n - maxm << endl;
}
