#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
long long mod = 1e18;
bool remender(long long a, long long b) { return a % b; }
void solve() {
  int n;
  cin >> n;
  int q;
  cin >> q;
  int arr[n];
  int mn[200001], mx[200001];
  for (int i = 0; i <= 200000; i++) {
    mn[i] = 1e6, mx[i] = -1;
  }
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mn[arr[i]] = min(mn[arr[i]], i);
    mx[arr[i]] = max(mx[arr[i]], i);
  }
  vector<int> v;
  int r = 0;
  for (int i = 0; i < n; i++) {
    if (r < i) v.push_back(r);
    if (mx[arr[i]] > r) {
      r = mx[arr[i]];
    }
  }
  v.push_back(r);
  unordered_map<int, int> cnt;
  int j = 0;
  int mxx = -1, c = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cnt[arr[i]]++;
    mxx = max(mxx, cnt[arr[i]]);
    c++;
    if (v[j] == i) {
      ans += c - mxx;
      mxx = -1;
      c = 0;
      j++;
      cnt.clear();
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
