#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
const int64_t INF = 1e18;
const int64_t eps = 1e-18;
void io(string s1 = "input.txt", string s2 = "output.txt") {
  freopen(s1.c_str(), "r", stdin);
  freopen(s2.c_str(), "w", stdout);
}
int64_t dp[5000][5001], v[5000];
int64_t n, m;
int64_t f(int64_t i, int64_t lst) {
  if (i == n) return 0;
  int64_t &ans = dp[i][lst];
  if (ans) return ans;
  ans = f(i + 1, lst);
  if (v[i] >= lst) {
    ans = max(ans, 1 + f(i + 1, v[i]));
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int64_t i = 0; i < n; i++) {
    cin >> v[i];
    long double d;
    cin >> d;
  }
  cout << n - f(0, 0);
}
