#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  vector<int> a(n), dp(n, 1);
  for (int i = 0; i < n; ++i) {
    double junk;
    cin >> a[i] >> junk;
  }
  int lis = 1;
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      if (a[i] >= a[j]) dp[i] = max(dp[i], 1 + dp[j]);
    }
    lis = max(lis, dp[i]);
  }
  cout << n - lis << "\n";
  return 0;
}
