#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 5;
const int INF = 1000000000;
int dp[maxn];
int num[maxn];
int main() {
  int n, m;
  int ans;
  while (cin >> n >> m) {
    double y;
    ans = 0;
    for (int i = 0; i < n; i++) cin >> num[i] >> y;
    for (int i = 0; i < n; i++) {
      int Max = 0;
      dp[i] = 1;
      for (int j = 0; j < i; j++) {
        if (num[j] <= num[i]) Max = max(Max, dp[j]);
      }
      dp[i] += Max;
      ans = max(ans, dp[i]);
    }
    cout << n - ans << endl;
  }
  return 0;
}
