#include <bits/stdc++.h>
using namespace std;
int a[200000];
vector<int> pos[200001];
int diff[200000];
vector<int> adjList[200001];
int visited[200000], m = 0, s = 0;
int doDFS(int u) {
  if (visited[u]) return 0;
  int i;
  visited[u] = 1, m = max(m, (int)pos[u].size()), s += pos[u].size();
  for (i = 0; i < adjList[u].size(); i++) doDFS(adjList[u][i]);
  return 0;
}
int main() {
  int i;
  int n, q;
  scanf("%d %d", &n, &q);
  for (i = 0; i < n; i++) scanf("%d", &a[i]), pos[a[i]].push_back(i);
  for (i = 0; i < 200001; i++) {
    if (pos[i].size() >= 2) diff[pos[i][0]]++, diff[pos[i].back()]--;
  }
  for (i = 1; i < n - 1; i++) diff[i] += diff[i - 1];
  for (i = 0; i < n - 1; i++) {
    if (diff[i] > 0)
      adjList[a[i]].push_back(a[i + 1]), adjList[a[i + 1]].push_back(a[i]);
  }
  int ans = 0;
  for (i = 0; i < 200001; i++) {
    if (!adjList[i].empty()) m = s = 0, doDFS(i), ans += s - m;
  }
  printf("%d\n", ans);
  return 0;
}
