#include <bits/stdc++.h>
using namespace std;
const int MX = 200000;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  vector<int> last(MX + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    last[a[i]] = i;
  }
  int ans = 0;
  for (int i = 0; i < n;) {
    int next = last[a[i]];
    map<int, int> freq;
    int mx = 0, cnt = 0;
    while (1) {
      int tmp = -1;
      for (int j = i; j <= next; j++) {
        tmp = max(tmp, last[a[j]]);
        mx = max(mx, ++freq[a[j]]);
        cnt++;
      }
      if (tmp <= next) {
        break;
      }
      i = next + 1;
      next = tmp;
    }
    ans += cnt - mx;
    i = next + 1;
  }
  cout << ans << '\n';
  return 0;
}
