#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100010], d[100010];
double f[100010];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i] >> f[i];
  for (int i = 1; i <= n; ++i)
    d[a[i]] = max(d[a[i]], (*max_element(d, d + a[i] + 1)) + 1);
  cout << n - (*max_element(d, d + n + 1)) << endl;
}
