#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int inf = (int)1e9;
const int maxn = 5010;
int s[maxn];
double x[maxn];
int d[maxn][maxn];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; (i) < (n); ++(i)) scanf("%d%lf", &s[i], &x[i]);
  for (int i = 0; (i) < (n + 1); ++(i))
    for (int j = 0; (j) < (m); ++(j)) d[i][j] = inf;
  d[0][0] = 0;
  for (int i = 0; (i) < (n + 1); ++(i))
    for (int j = 0; (j) < (m); ++(j))
      if (d[i][j] < inf) {
        if (s[i] == j + 1)
          d[i + 1][j] = min(d[i + 1][j], d[i][j]);
        else
          d[i + 1][j] = min(d[i + 1][j], d[i][j] + 1);
        if (j < m - 1) d[i][j + 1] = min(d[i][j + 1], d[i][j]);
      }
  printf("%d\n", d[n][m - 1]);
  return 0;
}
