#include <bits/stdc++.h>
using namespace std;
long long ksm(long long a, long long b) {
  if (!b) return 1;
  long long ns = ksm(a, b >> 1);
  ns = ns * ns % 998244353;
  if (b & 1) ns = ns * a % 998244353;
  return ns;
}
struct th {
  int l, r, cnt;
  th() { l = 200005, r = 0, cnt = 0; }
  bool operator<(const th &s) const { return l < s.l; }
} p[200005];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    p[a].l = min(i, p[a].l), p[a].cnt++;
    p[a].r = i;
  }
  sort(p, p + 200005);
  int ans = 0;
  for (int i = 0; i < 200005;) {
    if (p[i].l == 200005) break;
    int rr = p[i].r, mx = 0;
    int j = i;
    while (j < 200005 && p[j].l <= rr) {
      mx = max(mx, p[j].cnt), rr = max(rr, p[j].r), j++;
    }
    ans += mx;
    i = j;
  }
  cout << n - ans << endl;
  return 0;
}
