#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2e5 + 10;
int n, cnt;
struct node {
  int l, r, sum;
} a[Maxn];
map<int, int> m;
bool cmp(node x, node y) { return x.l < y.l; }
int main() {
  int q;
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (!m.count(x)) {
      m[x] = ++cnt;
      a[cnt].l = a[cnt].r = i;
      a[cnt].sum = 1;
    } else {
      int to = m[x];
      a[to].r = i;
      a[to].sum++;
    }
  }
  sort(a + 1, a + 1 + cnt, cmp);
  for (int i = 1; i <= cnt; i++) {
  }
  int ans = 0;
  int now = a[1].r, b = 0, res = a[1].sum;
  for (int i = 2; i <= cnt; i++) {
    if (a[i].l < now)
      now = max(a[i].r, now), res = max(res, a[i].sum);
    else {
      ans += now - b - res;
      res = a[i].sum;
      b = now, now = a[i].r;
    }
  }
  ans += now - b - res;
  cout << ans;
}
