#include <bits/stdc++.h>
using namespace std;
const long long int M = 1e9 + 7, maxn = 2e5 + 10, maxx = 1e6 + 10;
long long int ans, n, k, m, x, y, q, cnt[maxn], p[maxx], a[maxn], r = 1, l = 1,
                                                                  rr, ll;
bool mark[maxn];
int32_t main() {
  cin >> n >> q;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++)
    if (!mark[a[i]]) {
      p[i]++;
      mark[a[i]] = 1;
    }
  fill(mark, mark + maxn, 0);
  for (long long int i = n - 1; i >= 0; i--)
    if (!mark[a[i]]) {
      p[i]--;
      mark[a[i]] = 1;
    }
  for (long long int i = 1; i <= n; i++) p[i] += p[i - 1];
  for (long long int i = 0; i <= n; i++) {
    cnt[a[i]]++;
    k++;
    m = max(m, cnt[a[i]]);
    if (p[i] == 0) {
      ans += (k - m);
      k = 0;
      m = 0;
    }
  }
  cout << ans;
  return 0;
}
