#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, q, a[N], b[N], tot;
struct info {
  int a, b, c;
} d[N];
template <typename T>
inline void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
inline void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
  x *= f;
}
inline bool cmp(info a, info b) { return a.a < b.a; }
int vis[N], mx[N];
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) {
    d[i].a = n + 1;
    d[i].b = 0;
    d[i].c = 0;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  tot = unique(b + 1, b + n + 1) - b - 1;
  for (int i = 1; i <= n; ++i) a[i] = lower_bound(b + 1, b + 1 + tot, a[i]) - b;
  for (int i = 1; i <= n; ++i) {
    chkmin(d[a[i]].a, i);
    chkmax(d[a[i]].b, i);
    ++d[a[i]].c;
  }
  sort(d + 1, d + tot + 1, cmp);
  int ptr = 2;
  for (int i = 1; i <= tot; ++i) {
    if (vis[i]) continue;
    vis[i] = 1;
    mx[i] = d[i].c;
    for (; ptr <= tot; ++ptr) {
      if (d[ptr].a > d[i].b) break;
      chkmax(d[i].b, d[ptr].b);
      vis[ptr] = 1;
      chkmax(mx[i], d[ptr].c);
    }
  }
  int ans = n;
  for (int i = 1; i <= tot; ++i) ans -= mx[i];
  printf("%d\n", ans);
  return 0;
}
