#include <bits/stdc++.h>
const int MAXN = 2e5 + 5, MAXM = 4e5 + 5, MOD = 100003, INF = 0x3f3f3f3f,
          N = 2e5;
const long long INFL = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
using namespace std;
int n, q, a[MAXN], l[MAXN], r[MAXN], cnt[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> q;
  for (int i = 1; i <= N; i++) l[i] = n + 1, r[i] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    l[a[i]] = min(l[a[i]], i);
    r[a[i]] = max(r[a[i]], i);
    cnt[a[i]]++;
  }
  int i = 1, sum = 0;
  while (i <= n) {
    int right = r[a[i]], mx = 0;
    while (i <= right) {
      right = max(right, r[a[i]]);
      mx = max(mx, cnt[a[i]]);
      i++;
    }
    sum += mx;
  }
  cout << n - sum << '\n';
  return 0;
}
