#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, q, cnt = 0, dl = 0;
  cin >> n >> q;
  vector<long long> v(n);
  map<long long, long long> used, used1;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    used1[v[i]]++;
  }
  vector<long long> v1;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (used[v[i]] == 0) {
      cnt++;
      used[v[i]] = 1;
      dl++;
      v1.push_back(v[i]);
    } else {
      used[v[i]]++;
      dl++;
    }
    if (used[v[i]] == used1[v[i]]) {
      cnt--;
    }
    if (cnt == 0) {
      long long mx = 0;
      for (auto to : v1) {
        mx = max(mx, used1[to]);
      }
      ans += dl - mx;
      dl = 0;
      v1.clear();
    }
  }
  cout << ans;
}
