#include <bits/stdc++.h>
using namespace std;
const int maxn = 200007;
vector<int> v[maxn];
set<int> s;
pair<int, int> pr[maxn];
int a[maxn], cnt[maxn];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
    v[a[i]].push_back(i);
    s.insert(a[i]);
  }
  for (int x : s) pr[x] = pair<int, int>(v[x][0], v[x][v[x].size() - 1]);
  int ans = 0;
  for (int i = 1; i <= n;) {
    int r = pr[a[i]].second, mx = 0;
    for (int j = i; j <= r; j++) {
      r = max(r, pr[a[j]].second);
      mx = max(mx, cnt[a[j]]);
    }
    ans += r - i + 1 - mx;
    i = r + 1;
  }
  printf("%d\n", ans);
  return 0;
}
