#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, M = 18;
int n, q, a[N], seg[N * 4], last[N], cnt[N];
void pre() {
  for (int i = 0; i < n; i++) last[a[i]] = max(i, last[a[i]]), cnt[a[i]]++;
}
void operate() {
  int bit = 0, cur = 0, cmt = 0, ans = 0, mx = 0;
  for (int i = 0; i < n; i++) {
    if (!bit) {
      if (last[a[i]] - i + 1 == cnt[a[i]])
        i = last[a[i]];
      else
        bit = 1, cur = last[a[i]], mx = max(mx, cnt[a[i]]), cmt = 1;
    } else {
      cur = max(cur, last[a[i]]);
      cmt++;
      mx = max(mx, cnt[a[i]]);
      if (cur == i) {
        ans += cmt - mx;
        cmt = 0, cur = 0, mx = 0;
        bit = 0;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  pre();
  operate();
}
