#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> g[N * 5];
int ct[N * 5], mn[N * 5], mx[N * 5], a[N];
int z = 0;
bool used[N * 5];
int sum = 0, mx_ct = 0;
int build(int L, int R) {
  int v = z++;
  if (L == R) {
    g[v].push_back(a[L]);
  } else {
    int m = (L + R) >> 1;
    g[v] = {build(L, m), build(m + 1, R)};
  }
  return v;
}
void que(int l, int r, int x, int v, int L, int R) {
  if (l > r) return;
  if (l == L && r == R) {
    g[x].push_back(v);
  } else {
    int m = (L + R) >> 1;
    que(l, min(m, r), x, g[v][0], L, m);
    que(max(m + 1, l), r, x, g[v][1], m + 1, R);
  }
}
void dfs(int node) {
  used[node] = 1;
  sum += ct[node];
  mx_ct = max(mx_ct, ct[node]);
  for (int to : g[node]) {
    if (!used[to]) {
      dfs(to);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < N; i++) {
    mn[i] = -1;
    mx[i] = -1;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
    ct[a[i]]++;
    mx[a[i]] = i;
  }
  for (int i = n - 1; i >= 0; i--) {
    mn[a[i]] = i;
  }
  z = N;
  int rt = build(0, n - 1);
  for (int i = 0; i < N; i++) {
    if (mn[i] != -1) {
      que(mn[i], mx[i], i, rt, 0, n - 1);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!used[a[i]]) {
      sum = 0;
      mx_ct = 0;
      dfs(a[i]);
      ans += sum - mx_ct;
    }
  }
  cout << ans;
  return 0;
}
