#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  vector<int> v(n);
  vector<int> mm((long long)2e5 + 1), mx((long long)2e5 + 1),
      nr((long long)2e5 + 1);
  for (auto &e : mm) e = n;
  for (int i = 0; i < (int)n; i++) {
    int e;
    scanf("%d", &e);
    mm[e] = min(mm[e], i);
    mx[e] = max(mx[e], i);
    nr[e]++;
    v[i] = e;
  }
  int ret = 0, mp = 0;
  for (int i = n - 1; i >= 0;) {
    int ni = mm[v[i]];
    int origi = i;
    mp = 0;
    mp = max(mp, nr[v[i]]);
    for (; i >= ni; i--) {
      mp = max(mp, nr[v[i]]);
      ni = min(mm[v[i]], ni);
    }
    ret += origi - ni - mp + 1;
  }
  printf("%d\n", ret);
  return 0;
}
