#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  double f;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i] >> f;
  int dp[m + 1], mx, x;
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n; ++i) {
    x = a[i];
    mx = 0;
    for (int j = 1; j <= x; j++) mx = max(mx, dp[j]);
    dp[x] = mx + 1;
  }
  cout << n - *max_element(dp, dp + m + 1);
}
