#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 100, M = 20, LG = 30, base = 2;
const long long MOD = 1e9 + 7, mod = 1e9 + 9;
const long long INF = 1e9, inf = 1e18;
long long n, m, x;
long long p[N], dp[N], s[N];
long double pashm[N];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  long long havij;
  cin >> n >> havij;
  for (int i = 0; i < n; i++) {
    cin >> p[i] >> pashm[i];
    dp[i] = INF;
  }
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    x = upper_bound(dp, dp + n, p[i]) - dp;
    s[i] = x;
    dp[x] = min(dp[x], p[i]);
    m = max(m, s[i]);
  }
  cout << n - m;
  return 0;
}
