#include <bits/stdc++.h>
using namespace std;
const long long M = 2e5 + 5;
long long n, q, ans, a[M], st[M], en[M];
void merge(vector<pair<long long, long long> > &v) {
  sort(v.begin(), v.end());
  long long prev = 0;
  for (long long i = 1; i < (long long)v.size(); i++) {
    if (v[prev].second > v[i].first)
      v[prev].second = max(v[prev].second, v[i].second);
    else {
      ++prev;
      v[prev] = v[i];
    }
  }
  if (prev + 1 < (long long)v.size()) v.erase(v.begin() + prev + 1, v.end());
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (!st[a[i]]) st[a[i]] = i;
    en[a[i]] = i;
  }
  vector<pair<long long, long long> > v;
  for (long long i = 1; i < M; i++) {
    if (!st[i] || !en[i]) continue;
    v.push_back({st[i], en[i]});
  }
  merge(v);
  for (auto &p : v) {
    map<long long, long long> mp;
    for (long long i = p.first; i <= p.second; i++) mp[a[i]]++;
    long long mx = 0;
    for (auto it : mp) mx = max(mx, it.second);
    ans += (p.second - p.first + 1) - mx;
  }
  cout << ans;
  return 0;
}
