#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc = 1;
  while (tc--) {
    long long n, q;
    cin >> n >> q;
    long long f[200001], l[200001], a[n], b[n];
    for (int i = 1; i <= 200000; i++) f[i] = l[i] = -1;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (f[a[i]] == -1) f[a[i]] = i;
      l[a[i]] = i;
      b[i] = 0;
    }
    for (int i = 1; i <= 200000; i++) {
      if (f[i] < 0) continue;
      b[f[i]]++;
      b[l[i]]--;
    }
    long long c = 0, ma = 0, last = 0, ans = 0;
    map<long long, long long> mp;
    for (int i = 0; i < n; i++) {
      mp[a[i]]++;
      ma = max(ma, mp[a[i]]);
      c += b[i];
      if (!c) {
        ans += (i - last + 1 - ma);
        mp.clear();
        last = i + 1;
        ma = 0;
      }
    }
    cout << ans;
  }
  return 0;
}
