#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::map;
using std::vector;
using pii = std::pair<int, int>;
void solve() {
  int n, q;
  cin >> n >> q;
  map<int, pii> tm;
  vector<int> v(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    auto it = tm.find(v[i]);
    if (it != tm.end()) {
      it->second.second = i;
    } else {
      tm[v[i]] = {i, i};
    }
  }
  vector<int> cum(n, 0);
  for (auto const& lr : tm) {
    cum[lr.second.first] += 1;
    cum[lr.second.second] -= 1;
  }
  for (int i = 0; i < n - 1; ++i) {
    cum[i + 1] += cum[i];
  }
  int ans = 0;
  int pre = 0;
  int maxi = 0;
  map<int, int> tmcnt;
  for (int i = 0; i < n; ++i) {
    auto it = tmcnt.find(v[i]);
    if (it != tmcnt.end()) {
      it->second += 1;
      maxi = std::max(maxi, it->second);
    } else {
      tmcnt[v[i]] = 1;
      maxi = std::max(maxi, 1);
    }
    if (cum[i] == 0) {
      ans += i - pre - maxi;
      maxi = 0;
      pre = i;
      tmcnt.clear();
    }
  }
  ans += n - pre - maxi;
  cout << ans << endl;
}
int main(int argc, char* argv[]) {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();
}
