#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const long long int LINF = 1LL * INF * INF;
const int MAXN = 2e5 + 10;
const int MAXM = 5e3 + 10;
priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;
int A[MAXN];
int R[MAXN];
int cal[MAXN];
char S[MAXN];
int main() {
  int n, m, k, a, b, x, y, q;
  int sum = 0;
  int cnt = 0;
  int mx = 0;
  int mn = INF;
  int cur = 0, idx = -1;
  int tc;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> A[i];
  for (int i = 1; i <= n; i++) {
    cal[A[i]]++;
    R[A[i]] = i;
  }
  int pre = 0;
  int st = 0;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (pre < i) {
      res += (pre - mx - st);
      mx = cal[A[i]];
      pre = R[A[i]];
      st = i - 1;
    } else {
      pre = max(pre, R[A[i]]);
      mx = max(mx, cal[A[i]]);
    }
  }
  res += (pre - mx - st);
  cout << res << "\n";
  return 0;
}
