#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
mt19937_64 randGen(system_clock().now().time_since_epoch().count());
mt19937 rnd(42);
const int N = 2e5 + 1;
struct Solver {
  int n, q, a[N], r[N] = {}, mp[N] = {};
  int t[N] = {};
  void read() {
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      r[a[i]] = max(r[a[i]], i);
    }
  }
  void solve() {
    int p = 1;
    for (int i = 0; i < n; i++) {
      if (t[i]) {
        if (t[r[a[i]]] == 0) {
          for (int j = mp[t[i]]; j <= r[a[i]]; j++) {
            t[j] = t[i];
          }
          mp[t[i]] = max(mp[t[i]], r[a[i]]);
        }
        continue;
      }
      t[i] = p++;
      for (int j = i + 1; j <= r[a[i]]; j++) {
        t[j] = t[i];
      }
      mp[t[i]] = max(mp[t[i]], r[a[i]]);
    }
    int cur = 0, ans = 0;
    unordered_map<int, int> xp;
    int lp = 0, rp = 0;
    while (rp < n) {
      while (t[rp] == t[lp]) {
        rp++;
      }
      for (int i = lp; i <= rp && t[lp] == t[i]; i++) {
        xp[a[i]]++;
      }
      int sm = 0, mx = 0;
      for (auto e : xp) {
        sm += e.second;
        mx = max(mx, e.second);
      }
      xp.clear();
      ans += (sm - mx);
      lp = rp;
    }
    cout << ans;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Solver sol;
  sol.read();
  sol.solve();
  return 0;
}
