#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n), nxt(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<int, int> mp;
  for (int i = n - 1; i >= 0; i--) {
    if (mp.find(a[i]) != mp.end()) {
      nxt[i] = mp[a[i]];
    } else {
      nxt[i] = i;
      mp[a[i]] = i;
    }
  }
  mp.clear();
  int ans = 0, ind = 0;
  for (int i = 0; i < n; i++) {
    mp[a[i]]++;
    ind = max(ind, nxt[i]);
    if (ind == i) {
      int sum = 0, mx = 0;
      for (auto x : mp) {
        sum += x.second;
        mx = max(mx, x.second);
      }
      ans += sum - mx;
      mp.clear();
    }
  }
  cout << ans << endl;
  return 0;
}
