#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-10;
const long long mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxn = 200005;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 - '0');
}
int n, q;
int a[maxn], r[maxn], vis[maxn];
vector<pair<int, int> > v;
unordered_map<int, int> ma[maxn];
int main(void) {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    r[a[i]] = i;
  }
  int mxr = 0, st = 1;
  for (int i = 1; i <= n; i++) {
    if (!vis[a[i]]) {
      vis[a[i]] = 1;
      mxr = max(mxr, r[a[i]]);
    }
    if (i == mxr) {
      v.push_back(pair<int, int>(st, i));
      st = i + 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    for (int j = v[i].first; j <= v[i].second; j++) {
      ma[i][a[j]]++;
    }
    int sum = 0, mx = 0;
    for (auto e : ma[i]) {
      sum += e.second;
      mx = max(mx, e.second);
    }
    ans += (sum - mx);
  }
  printf("%d\n", ans);
  return 0;
}
