#include <bits/stdc++.h>
using namespace std;
const int ms = int(2e5) + 10;
int a[ms], n, l[ms], r[ms], par[ms];
vector<int> info[ms];
int find(int i) {
  if (par[i] == i) return i;
  return par[i] = find(par[i]);
}
void join(int i, int j) {
  int pi = find(i), pj = find(j);
  par[pj] = pi;
  for (auto x : info[pj]) info[pi].push_back(x);
  info[pj].clear();
}
int solve(vector<int> &v) {
  map<int, int> mp;
  int best = 0;
  for (auto x : v) {
    mp[x]++;
    if (mp[x] > best) best = mp[x];
  }
  return v.size() - best;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int p;
  cin >> n >> p;
  memset(l, -1, sizeof l);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (l[a[i]] == -1) l[a[i]] = i;
    r[a[i]] = i;
    par[i] = i;
    info[i].push_back(a[i]);
  }
  set<int> q;
  for (int i = 0; i < n; i++) {
    if (!q.empty()) {
      join(*q.begin(), i);
    }
    if (l[a[i]] == i) {
      q.insert(i);
    }
    if (!q.empty() && r[a[i]] == i) {
      q.erase(l[a[i]]);
    }
  }
  int ans = 0;
  set<int> go;
  for (int i = 0; i < n; i++) {
    go.insert(find(i));
  }
  for (auto x : go) {
    ans += solve(info[x]);
  }
  cout << ans << endl;
  return 0;
}
