#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 100;
const int md = 1000000007;
priority_queue<int, vector<int>, greater<int> > pq;
int n, q, arr[mx], ans = 0, cnt[mx] = {}, jarak[mx][2], color[mx] = {},
                   posTerakhir[mx];
vector<int> ars;
bool compare(int &a, int &b) { return cnt[a] > cnt[b]; }
int main() {
  memset(posTerakhir, -1, sizeof(posTerakhir));
  memset(jarak, -1, sizeof(jarak));
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i += 1) {
    scanf("%d", &arr[i]);
    int z = arr[i];
    color[z] = z;
    if (cnt[z] == 0) {
      ars.push_back(z);
      jarak[z][0] = i;
    }
    jarak[z][1] = i + 1;
    cnt[z]++;
  }
  sort(ars.begin(), ars.end(), compare);
  for (int i = 0; i < ars.size(); i += 1) {
    int z = ars[i];
    for (int j = jarak[z][0]; j < jarak[z][1]; j += 1) {
      if (posTerakhir[j] == -1)
        posTerakhir[j] = jarak[z][1];
      else {
        j = posTerakhir[j] - 1;
        continue;
      }
      int x = color[arr[j]], y = color[ars[i]];
      if (x != y) {
        if (cnt[x] > cnt[y]) {
          cnt[x] += cnt[y];
          cnt[y] = 0;
          color[ars[i]] = x;
        } else {
          cnt[y] += cnt[x];
          cnt[x] = 0;
          color[arr[j]] = y;
        }
      }
    }
  }
  for (int i = 0; i < n; i += 1) ans += color[arr[i]] != arr[i];
  printf("%d\n", ans);
}
