#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T& x) {
  x = 0;
  bool flg = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) flg |= ch == '-';
  for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
  flg ? x *= -1 : 233;
}
template <typename T>
void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
namespace _chhokmah {
const int N = 2e5 + 5;
int n, q, disc[N], dc, ans = 0;
int a[N];
struct _edge {
  int l, r, x;
  bool operator<(const _edge& rhs) const { return l < rhs.l; }
} edge[N];
set<int> st[N];
int main() {
  read(n);
  read(q);
  for (int i = 1; i <= n; i++) {
    read(a[i]), disc[++dc] = a[i];
  }
  sort(disc + 1, disc + 1 + dc);
  dc = unique(disc + 1, disc + 1 + dc) - disc - 1;
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(disc + 1, disc + 1 + dc, a[i]) - disc;
    st[a[i]].insert(i);
  }
  for (int i = 1; i <= dc; i++) {
    edge[i].l = *st[i].begin();
    set<int>::iterator it = st[i].end();
    it--;
    edge[i].r = *it;
    edge[i].x = st[i].size();
  }
  sort(edge + 1, edge + 1 + dc);
  if (!q) {
    int lst = 0, cur = 0;
    for (int i = 1; i <= dc; i++) {
      cur = max(cur, edge[i].r);
      if (i == dc || edge[i + 1].l > cur) {
        int tmp = 0;
        for (int j = lst + 1; j <= i; j++) {
          tmp = max(tmp, edge[j].x);
          ans += edge[j].x;
        }
        ans -= tmp;
        lst = i, cur = 0;
      }
    }
    write(ans);
  }
  return 0;
}
}  // namespace _chhokmah
int main() { return _chhokmah::main(); }
