#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5;
int n, q;
int a[maxn];
vector<int> V[maxn];
int cnt[maxn];
int ans = 0;
int gao(int l, int r) {
  unordered_map<int, int> mp;
  for (int i = l; i <= r; i++) mp[a[i]]++;
  int maxx = 0;
  for (auto &i : mp) {
    maxx = max(maxx, i.second);
  }
  return r - l + 1 - maxx;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    V[a[i]].push_back(i);
  }
  for (int i = 1; i <= 200000; i++) {
    sort(V[i].begin(), V[i].end());
  }
  int L = 1, R = -1;
  for (int i = 1; i <= n; i++) {
    R = max(R, V[a[i]].back());
    if (R == i) {
      ans += gao(L, R);
      L = R = i + 1;
    }
  }
  if (L <= n) ans += gao(L, n);
  cout << ans << endl;
  return 0;
}
