#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
int n, q;
int a[200005];
int ls[200005];
int lt[200005];
int nd[200005];
int dfs(int cn, int st, int c) {
  if (nd[cn] != 0) return 0;
  nd[cn] = c;
  int ans = cn;
  ans = max(ans, dfs(lt[cn], st, c));
  if (cn != st) ans = max(ans, dfs(cn - 1, st, c));
  return ans;
}
int cc(int l, int r) {
  map<int, int> hmm;
  for (int i = (l); i <= (signed)(r); i++) {
    hmm[a[i]]++;
  }
  int mx = 0;
  for (auto u : hmm) {
    mx = max(mx, u.second);
  }
  return mx;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 0; i < (signed)(n); i++) {
    cin >> a[i];
    ls[a[i]] = i;
  }
  for (int i = 0; i < (signed)(n); i++) {
    lt[i] = ls[a[i]];
  }
  int sm = 0;
  int co = 0;
  for (int i = 0; i < (signed)(n); i++) {
    if (nd[i] == 0) {
      int v = dfs(i, i, ++co);
      sm += cc(i, v);
    }
  }
  cout << n - sm << "\n";
  return 0;
}
