#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int type[n];
  for (long long i = 0; i < (n); ++i) {
    double pos;
    cin >> type[i] >> pos;
  }
  vector<int> ans;
  for (long long i = 0; i < (n); ++i) {
    auto it = upper_bound(ans.begin(), ans.end(), type[i]);
    if (it == ans.end())
      ans.push_back(type[i]);
    else
      *it = type[i];
  }
  cout << n - ans.size() << '\n';
  return 0;
}
