#include <bits/stdc++.h>
using namespace std;
int LIM = 2e5 + 10;
int n;
int main() {
  int q, i = 1;
  cin >> n >> q;
  long long int ans = 0;
  vector<long long int> last(n + 1, 0), arr(n + 1, 0), count(LIM, 0);
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    last[arr[i]] = i;
    count[arr[i]]++;
  }
  while (i <= n) {
    int start = i;
    long long int b = 0;
    long long int maxi = last[arr[i]];
    for (; i <= maxi; i++) {
      maxi = max(maxi, last[arr[i]]);
      b = max(b, count[arr[i]]);
    }
    ans += i - start - b;
  }
  cout << ans << endl;
  return 0;
}
