#include <bits/stdc++.h>
#pragma optimise GCC(-O2)
using namespace std;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
long long INF = 1e12;
const long long M = 1000000007;
long long powm(long long, long long);
long long dp[5005][5005] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  long long sp[n];
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    double y;
    cin >> y;
    sp[i] = x;
  }
  for (int i = 1; i < 5005; i++) dp[0][i] = INF;
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    long long z = sp[i];
    long long mn = INF;
    for (int j = 0; j < z; j++) {
      dp[i + 1][j] = dp[i][j] + 1;
      mn = min(mn, dp[i][j]);
    }
    mn = min(mn, dp[i][z]);
    dp[i + 1][z] = mn;
    for (int j = z + 1; j < 5005; j++) dp[i + 1][j] = dp[i][j] + 1;
  }
  long long ans = INF;
  for (int i = 0; i < 5005; i++) ans = min(ans, dp[n][i]);
  cout << ans << endl;
}
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % M;
    a = (a * a) % M;
    b >>= 1;
  }
  return res;
}
