#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 2;
int r[MAXN], freq[MAXN];
int main() {
  memset(r, -1, sizeof r);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    r[a[i]] = i;
  }
  function<int(int)> Solve = [&](int i) {
    if (i >= n) return 0;
    int rightmost = r[a[i]];
    int maxFreq = 0;
    int j = i;
    while (j <= rightmost) {
      freq[a[j]]++;
      rightmost = max(rightmost, r[a[j]]);
      maxFreq = max(maxFreq, freq[a[j]]);
      j++;
    }
    for (int k = i; k < j; k++) freq[a[k]] = 0;
    return (j - i - maxFreq) + Solve(j);
  };
  cout << Solve(0);
  return 0;
}
