#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long int inf64 = 1e18 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, i;
  cin >> n >> m;
  vector<pair<int, double> > v(n);
  for (i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end(),
       [](const pair<int, double> &p1, const pair<int, double> &p2) {
         if (p1.first == p2.first) return p1.second < p2.second;
         return p1.first < p2.first;
       });
  int dp[n];
  fill(dp, dp + n, 1);
  for (i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (v[i].second > v[j].second) dp[i] = max(dp[i], dp[j] + 1);
    }
  }
  cout << n - *max_element(dp, dp + n);
}
