#include <bits/stdc++.h>
using namespace std;
int n, q, a[200111], cnt[200111];
pair<pair<int, int>, int> ujung[200111];
vector<pair<pair<int, int>, int>> c;
vector<int> b;
int ans = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  int tertinggi = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    tertinggi = max(tertinggi, a[i]);
    cnt[a[i]]++;
    if (ujung[a[i]].first.first == 0) ujung[a[i]].first.first = i;
    ujung[a[i]].first.second = i;
    ujung[a[i]].second = a[i];
  }
  for (int i = 1; i <= tertinggi; i++) {
    if (ujung[i].first.first != 0) {
      c.push_back(
          make_pair(make_pair(ujung[i].first.first, ujung[i].first.second),
                    ujung[i].second));
    }
  }
  sort(c.begin(), c.end());
  int l = 0, r = -1;
  for (int i = 0; i < c.size(); i++) {
    if (r < c[i].first.first) {
      int cur = 0;
      for (int x = 0; x < b.size(); x++) {
        cur = max(cur, cnt[b[x]]);
      }
      b.clear();
      ans += (r - l + 1) - cur;
      l = c[i].first.first;
      r = c[i].first.second;
      b.push_back(c[i].second);
    } else {
      r = max(r, c[i].first.second);
      b.push_back(c[i].second);
    }
  }
  int cur = 0;
  for (int x = 0; x < b.size(); x++) {
    cur = max(cur, cnt[b[x]]);
  }
  ans += (r - l + 1) - cur;
  cout << ans << '\n';
  return 0;
}
