#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, q;
int mn[N], mx[N], cnt[N];
int a[N];
set<int> myset;
map<pair<int, int>, int> mymap;
int main() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (!mn[a[i]]) {
      mn[a[i]] = i + 1;
    }
    mx[a[i]] = i + 1;
    myset.insert(a[i]);
    cnt[a[i]]++;
  }
  vector<pair<int, int> > segs;
  for (auto x : myset) {
    pair<int, int> seg = make_pair(mn[x], mx[x]);
    segs.emplace_back(seg);
    mymap[seg] = x;
  }
  sort(segs.begin(), segs.end());
  segs.emplace_back(make_pair(n + 1, n + 1));
  int mx = 0;
  int sum = 0;
  int lim = 0;
  int res = 0;
  for (auto seg : segs) {
    if (seg.first > lim) {
      res += sum - mx;
      lim = seg.second;
      sum = mx = cnt[mymap[seg]];
    } else {
      lim = max(lim, seg.second);
      int quant = cnt[mymap[seg]];
      mx = max(mx, quant);
      sum += quant;
    }
  }
  cout << res;
  return 0;
}
