#include <bits/stdc++.h>
using namespace std;
const string yno[2] = {"NO\n", "YES\n"};
int n, k, dem[200005], l[200005], r[200005];
struct bg {
  int l, r, t, mx;
};
bool operator<(const bg &a, const bg &b) { return a.l < b.l; }
void process() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (l[x])
      l[x] = min(l[x], i);
    else
      l[x] = i;
    r[x] = max(r[x], i);
    dem[x]++;
  }
  vector<bg> a;
  for (int i = 1; i <= 200000; i++) {
    if (dem[i]) {
      a.push_back({l[i], r[i], dem[i], dem[i]});
    }
  }
  sort(a.begin(), a.end());
  int pos = 0;
  for (int i = 1; i < a.size(); i++) {
    if (a[i].l > a[pos].r) {
      pos++;
      a[pos] = a[i];
    } else {
      a[pos].r = max(a[pos].r, a[i].r);
      a[pos].mx = max(a[pos].mx, a[i].mx);
      a[pos].t += a[i].t;
    }
  }
  a.resize(pos + 1);
  long long ans = 0;
  for (bg &i : a) {
    ans += i.t - i.mx;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  process();
  return 0;
}
