#include <bits/stdc++.h>
using namespace std;
int a[300000];
struct st {
  int l, r, c;
};
st p[300000];
int main() {
  int n, q;
  cin >> n >> q;
  const int C = 200000;
  for (int i = 0; i < C; i++) p[i].l = INT_MAX, p[i].r = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i]--;
    p[a[i]].l = min(p[a[i]].l, i);
    p[a[i]].r = max(p[a[i]].r, i);
    p[a[i]].c++;
  }
  vector<st> v;
  for (int i = 0; i < C; i++) {
    if (p[i].c) v.push_back(p[i]);
  }
  sort(v.begin(), v.end(), [](st a, st b) { return a.l < b.l; });
  int cnt = 0;
  int Max = -1;
  map<int, int> mps, mpMax;
  for (auto p : v) {
    if (Max < p.l) cnt++;
    mps[cnt] += p.c;
    mpMax[cnt] = max(mpMax[cnt], p.c);
    Max = max(Max, p.r);
  }
  int ans = 0;
  for (auto p : mps) {
    ans += p.second - mpMax[p.first];
  }
  cout << ans << endl;
}
