#include <bits/stdc++.h>
using namespace std;
void mohammed() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
int n, arr[5001], m;
int memo[5001][5001];
int solve(int i, int lastI) {
  if (i > n) return 0;
  int &ret = memo[i][lastI];
  if (ret != -1) return ret;
  if (arr[i] >= arr[lastI]) ret = solve(i + 1, i) + 1;
  return ret = max(solve(i + 1, lastI), ret);
}
int main() {
  mohammed();
  cin >> n >> m;
  double x;
  memset(memo, -1, sizeof memo);
  for (int i = 1; i <= n; i++) {
    cin >> arr[i] >> x;
  }
  cout << n - solve(1, 0);
  return 0;
}
