#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int memo[6000][6000];
int f(int ind, int pos) {
  if (ind == v.size()) return 0;
  int res = 1e8;
  int &ret = memo[ind][pos];
  if (ret != -1) return ret;
  if (pos != v[ind])
    res = min(res, 1 + f(ind + 1, pos));
  else
    res = min(res, f(ind + 1, pos));
  if (pos < v[ind]) res = min(res, f(ind + 1, v[ind]));
  return ret = res;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int(i) = 0; (i) < (n); (i)++) {
    int k;
    double t;
    cin >> k >> t;
    v.push_back(k);
  }
  for (int(i) = 0; (i) < (6000); (i)++)
    for (int(j) = 0; (j) < (6000); (j)++) memo[i][j] = -1;
  cout << f(0, 1) << endl;
}
