#include <bits/stdc++.h>
using namespace std;
const int MAX = 5009;
int n, m, a[MAX];
int memo[MAX][MAX];
int dp(int i, int cur) {
  if (i == n) return 0;
  int& ret = memo[i][cur];
  if (ret != -1) return ret;
  ret = (a[i] != cur) + dp(i + 1, cur);
  if (a[i] > cur) ret = min(ret, dp(i + 1, a[i]));
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    double d;
    cin >> d;
  }
  memset(memo, -1, sizeof memo);
  cout << dp(0, 1);
  return 0;
}
