#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], v[5000];
int64_t n, m;
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;
  }
  for (int64_t i = 0; i < n; i++) {
    dp[i] = 1;
    for (int64_t j = 0; j < i; j++) {
      if (v[j] <= v[i]) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
  }
  cout << n - *max_element(dp, dp + n);
}
