#include <bits/stdc++.h>
using namespace std;
int parent[200005];
int last[200005];
int cnts[200005];
int cnt2[200005];
bool cur[200005];
int get_root(int node) {
  if (parent[node] == -1) return node;
  parent[node] = get_root(parent[node]);
  return parent[node];
}
inline void merge(int a, int b) {
  if (get_root(a) == get_root(b)) return;
  parent[get_root(a)] = get_root(b);
}
inline bool connected(int a, int b) { return (get_root(a) == get_root(b)); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q, cur_size = 0, cnt;
  cin >> n >> q;
  int arr[n];
  vector<int> present;
  for (int x = 0; x < n; x++) {
    cin >> arr[x];
    last[arr[x]] = x;
  }
  for (int x = 0; x <= 200000; x++) {
    parent[x] = -1;
  }
  for (int x = 0; x < n; x++) {
    if (present.size() > 0) merge(present.back(), arr[x]);
    if (cur[arr[x]] == false) {
      cur[arr[x]] = true;
      cur_size++;
      present.push_back(arr[x]);
    }
    if (last[arr[x]] == x) {
      cur[arr[x]] = false;
      cur_size--;
    }
    while (present.size() > 0 && cur[present.back()] == false) {
      present.pop_back();
    }
  }
  sort(arr, arr + n);
  cnts[get_root(arr[0])]++;
  cnt = 1;
  for (int x = 1; x < n; x++) {
    if (arr[x] != arr[x - 1]) {
      cnt2[get_root(arr[x - 1])] = max(cnt2[get_root(arr[x - 1])], cnt);
      cnt = 1;
      cnts[get_root(arr[x])]++;
    } else {
      cnt++;
      cnts[get_root(arr[x])]++;
    }
  }
  cnt2[get_root(arr[n - 1])] = max(cnt2[get_root(arr[n - 1])], cnt);
  cur_size = 0;
  for (int x = 0; x < 200005; x++) {
    cur_size += max(cnts[x] - cnt2[x], 0);
  }
  cout << cur_size;
  return 0;
}
