#include <bits/stdc++.h>
using namespace std;
int n, q;
int a[200005], l[200005], r[200005], cnt[200005];
struct node {
  int l, r, tot;
};
vector<node> v;
bool cmp(node x, node y) { return x.l < y.l; }
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= 200000; i++) l[i] = 1000000000, r[i] = -1000000000;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    l[a[i]] = min(l[a[i]], i);
    r[a[i]] = max(r[a[i]], i);
    cnt[a[i]]++;
  }
  for (int i = 1; i <= 200000; i++) {
    if (cnt[i]) {
      v.push_back((node){l[i], r[i], cnt[i]});
    }
  }
  sort(v.begin(), v.end(), cmp);
  int curl = 1000000000, curr = -1, ans = 0, maxi = -1000000000;
  for (int i = 0; i < (int)v.size(); i++) {
    if (curl == 1000000000) {
      curl = v[i].l;
      curr = v[i].r;
      maxi = v[i].tot;
    } else if (v[i].l > curr) {
      ans += maxi;
      maxi = v[i].tot;
      curl = v[i].l;
      curr = v[i].r;
    } else {
      maxi = max(maxi, v[i].tot);
      curl = min(curl, v[i].l);
      curr = max(curr, v[i].r);
    }
  }
  if (maxi != -1000000000) ans += maxi;
  printf("%d\n", n - ans);
  return 0;
}
