#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj(200005);
int vis[200005], in[200005], f[200005], l[200005], val[200005];
int tmp1 = 0, tmp2 = 0;
int res = 0;
vector<int> dif;
void dfs(int x) {
  vis[x] = 1;
  tmp1 += val[x];
  tmp2 = max(tmp2, val[x]);
  for (int i = 0; i < adj[x].size(); i++) {
    int child = adj[x][i];
    if (!vis[child]) {
      dfs(child);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(f, -1, sizeof f);
  int n, q;
  cin >> n >> q;
  int ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    val[ar[i]]++;
    l[ar[i]] = i;
    if (f[ar[i]] == -1) {
      f[ar[i]] = i;
      dif.push_back(ar[i]);
    }
  }
  priority_queue<pair<int, int>> pq;
  for (int i = 0; i < n; i++) {
    while (!pq.empty()) {
      if (pq.top().first >= i) {
        break;
      } else {
        pq.pop();
      }
    }
    if (!in[ar[i]]) {
      pq.push({l[ar[i]], ar[i]});
      in[ar[i]] = 1;
    }
    if (pq.top().second == ar[i]) {
      continue;
    } else {
      adj[pq.top().second].push_back(ar[i]);
      adj[ar[i]].push_back(pq.top().second);
    }
  }
  for (int i = 0; i < dif.size(); i++) {
    tmp1 = 0;
    tmp2 = 0;
    if (!vis[dif[i]]) {
      dfs(dif[i]);
    }
    res += tmp1 - tmp2;
  }
  cout << res << endl;
  return 0;
}
