#include <bits/stdc++.h>
using namespace std;
pair<int, int> f[200005];
int getsoo[200005];
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  int a[n + 1];
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    ++getsoo[a[i]];
    if (f[a[i]].first == 0) f[a[i]].first = i;
  }
  for (int i = n; i >= 1; --i) {
    if (f[a[i]].second == 0) f[a[i]].second = i;
  }
  int change = 0;
  int curleft = 1;
  while (curleft <= n) {
    int curnum = a[curleft];
    int mostright = f[curnum].second;
    int mostinrange = 0;
    for (int i = curleft; i <= mostright; ++i) {
      mostinrange = max(mostinrange, getsoo[a[i]]);
      mostright = max(mostright, f[a[i]].second);
    }
    int all = mostright - curleft + 1;
    change += (all - mostinrange);
    curleft = mostright + 1;
  }
  printf("%d", change);
}
