#include <bits/stdc++.h>
using namespace std;
struct union_find {
  vector<int> p;
  union_find(int n) : p(n, -1) {}
  bool join(int u, int v) {
    if ((u = root(u)) == (v = root(v))) return false;
    if (p[u] > p[v]) swap(u, v);
    p[u] += p[v];
    p[v] = u;
    return true;
  }
  int root(int u) { return p[u] < 0 ? u : p[u] = root(p[u]); }
  int size(int u) { return -p[root(u)]; }
};
struct info {
  int l, r, c, id;
  bool operator<(const info &o) const {
    return make_pair(l, r) < make_pair(o.l, o.r);
  }
};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  map<int, int> fst, mp, last;
  for (int i = 0; i < n; ++i) {
    ++mp[a[i]];
    last[a[i]] = i;
    if (!fst.count(a[i])) fst[a[i]] = i;
  }
  int id = 0;
  vector<info> v;
  for (auto &i : fst) v.push_back({i.second, last[i.first], mp[i.first], id++});
  sort(v.begin(), v.end());
  union_find uf(id);
  vector<int> vals(id);
  for (int i = 0; i < id; ++i) vals[i] = v[i].c;
  int r = -1, root;
  for (auto i : v) {
    if (i.l <= r) {
      r = max(r, i.r);
      int va = vals[uf.root(root)];
      int vb = vals[uf.root(i.id)];
      uf.join(root, i.id);
      root = uf.root(root);
      vals[root] = max(va, vb);
    } else {
      r = i.r;
      root = uf.root(i.id);
      vals[root] = i.c;
    }
  }
  int ans = n;
  for (int i = 0; i < id; ++i) {
    int r = uf.root(i);
    ans -= vals[r];
    vals[r] = 0;
  }
  cout << ans << "\n";
  return 0;
}
