#include <bits/stdc++.h>
using namespace std;
int n, q, mx, ans;
int c[200005], f[200005], ct[200005], g[200005];
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
struct ao {
  int l, r, id;
} a[200005];
int cmp(ao p1, ao p2) { return p1.l == p2.l ? p1.r < p2.r : p1.l < p2.l; }
void work() {
  int p = q = 1;
  while (p <= mx) {
    if (a[p].r <= 0) {
      p++;
      continue;
    }
    while (a[q].r < a[p].l && q <= mx) q++;
    if (q <= mx) f[find(a[p].id)] = find(a[q].id);
    p++;
  }
  for (int i = 1; i <= n; i++) ct[c[i]]++;
  ans = n;
  for (int i = 1; i <= mx; i++) g[find(i)] = max(g[find(i)], ct[i]);
  for (int i = 1; i <= mx; i++)
    if (find(i) == i) ans -= g[find(i)];
  cout << ans << endl;
}
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    mx = max(mx, c[i]);
    f[c[i]] = c[i];
    if (!a[c[i]].l) a[c[i]].l = i;
    a[c[i]].r = i;
    a[c[i]].id = c[i];
  }
  sort(a + 1, a + mx + 1, cmp);
  work();
  return 0;
}
