#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
vector<string> parse(string s, string c) {
  int len = c.length(), p = -len, np;
  vector<string> ans;
  do {
    np = s.find(c, p + len);
    ans.push_back(s.substr(p + len, np - p - len));
    p = np;
  } while (p != string::npos);
  return ans;
}
int in[5500];
int dp[5500];
int main() {
  int n, m;
  double tp;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> in[i] >> tp;
  memset(dp, 0, sizeof(dp));
  dp[1] = 1;
  int mx = 1;
  for (int i = 2; i <= n; i++) {
    dp[i] = 1;
    for (int j = 1; j < i; j++)
      if (in[j] <= in[i]) dp[i] = max(dp[i], dp[j] + 1);
    mx = max(mx, dp[i]);
  }
  cout << n - mx << endl;
  return 0;
}
