#include <bits/stdc++.h>
using namespace std;
const int maxN = 200005;
int main() {
  std::ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> a(n), last(maxN), cnt(maxN);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    last[a[i]] = i;
    cnt[a[i]]++;
  }
  int pre = 0, tail = 0, ans = n;
  for (int i = 0; i < n; i++) {
    tail = max(tail, last[a[i]]);
    if (tail != i) continue;
    int max_val = 0;
    tail++;
    while (pre < tail) max_val = max(max_val, cnt[a[pre++]]);
    ans -= max_val;
  }
  cout << ans << "\n";
  return 0;
}
