#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
int n, m;
int dp[maxn];
int arr[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    double x;
    scanf("%d%lf", &arr[i], &x);
  }
  for (int i = 1; i <= n; ++i) {
    int j = arr[i];
    for (int k = j; k >= 1; k--) {
      dp[j] = max(dp[j], dp[k] + 1);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, dp[i]);
  }
  printf("%d\n", n - ans);
}
