#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 10, N2 = 4e6, delta = 46639, mod = 998244353,
                    oo = 1e18, LOG = 20;
const long double PI = 3.141592653589793;
long long int a[N], dp[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long int n, m, ans = 1;
  cin >> n >> m;
  for (long long int i = 0; i < n; i++) {
    long double x;
    cin >> a[i] >> x;
  }
  dp[0] = a[0];
  for (long long int i = 1; i < n; i++) {
    bool vis = false;
    for (long long int j = 0; j < ans; j++)
      if (dp[j] > a[i]) {
        vis = true;
        dp[j] = a[i];
        break;
      }
    if (!vis) dp[ans++] = a[i];
  }
  cout << n - ans << '\n';
  return 0;
}
