#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long mul(long long a, long long b) { return (a % mod * b % mod) % mod; }
long long pwr(long long x, long long e) {
  long long res = 1;
  while (e) {
    if (e & 1) {
      res = mul(res, x);
    }
    x = mul(x, x);
    e /= 2;
  }
  return res;
}
long long sqrtk(long long n) {
  long long k = sqrt(n);
  for (long long i = -2; i <= 2; i++)
    if (k + i >= 0 && (k + i) * (k + i) == n) return k;
  return -1;
}
long long vis[200001];
vector<long long> adj[200001];
void dfs(long long n) {
  vis[n] = 1;
  for (auto it : adj[n])
    if (vis[it] == 0) dfs(it);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, q;
  cin >> n >> q;
  long long arr[n + 1];
  long long b[200001] = {0};
  long long ff[200001] = {0};
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    b[arr[i]] = max(b[arr[i]], i);
    ff[arr[i]]++;
  }
  long long sum = 0;
  set<long long> s;
  long long mx = 1;
  for (long long i = 1; i <= n; i++) {
    long long k = arr[i];
    mx = max(mx, b[arr[i]]);
    s.insert(arr[i]);
    if (mx <= i) {
      long long temp = 0;
      for (auto it : s) {
        temp = max(temp, ff[it]);
        sum += ff[it];
      }
      sum -= temp;
      s.clear();
    }
  }
  cout << sum;
}
