#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, q, a[N], pos[N][2], maxn, cur[N], ans, tot, all, t, maxx;
struct store {
  int l, r;
  store(int ll = 0, int rr = 0) {
    l = ll;
    r = rr;
  }
  bool operator<(const store& e) const {
    return l < e.l || (l == e.l && r < e.r);
  };
} s[N], p[N];
inline bool Cross(store a, store b) { return a.l <= b.l && b.l <= a.r; }
int main() {
  scanf("%d%d", &n, &q);
  for (register int i = 1; i <= n; i++)
    scanf("%d", &a[i]), maxn = max(maxn, a[i]);
  for (register int i = 1; i <= maxn; i++) pos[i][0] = n + 1, pos[i][1] = 0;
  for (register int i = 1; i <= n; i++)
    pos[a[i]][0] = min(pos[a[i]][0], i), pos[a[i]][1] = max(pos[a[i]][1], i);
  for (register int i = 1; i <= maxn; i++)
    if (pos[i][1]) s[++tot] = store(pos[i][0], pos[i][1]);
  sort(s + 1, s + tot + 1);
  p[all = 1] = s[1];
  for (register int i = 2; i <= tot; i++)
    if (Cross(p[all], s[i]))
      p[all] = store(min(p[all].l, s[i].l), max(p[all].r, s[i].r));
    else
      p[++all] = s[i];
  for (register int i = 1; i <= all; i++) {
    t = p[i].r - p[i].l + 1;
    maxx = 0;
    for (register int j = p[i].l; j <= p[i].r; j++)
      maxx = max(maxx, ++cur[a[j]]);
    ans += t - maxx;
  }
  printf("%d\n", ans);
  return 0;
}
