#include <bits/stdc++.h>
using namespace std;
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const long long inf = 1e18;
int arr[M], mem[M][M];
int n, k;
int solve(int idx, int mxVal) {
  if (idx == n) return 0;
  int& ret = mem[idx][mxVal];
  if (~ret) return ret;
  ret = OO;
  if (arr[idx] >= mxVal) ret = solve(idx + 1, arr[idx]);
  ret = min(ret, solve(idx + 1, mxVal) + 1);
  return ret;
}
int main() {
  cout << fixed << setprecision(12), ios::sync_with_stdio(false),
      cin.tie(nullptr), cout.tie(nullptr);
  double temp;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> arr[i] >> temp;
  memset(mem, -1, sizeof mem);
  cout << solve(0, 0);
  return 0;
}
