#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool smin(T &a, const T &b) {
  return a > b ? a = b : a;
}
template <typename T>
inline bool smax(T &a, const T &b) {
  return a < b ? a = b : a;
}
const int N = (int)2e5 + 5, mod = (int)0;
set<int> xl[N];
set<int, greater<int>> xr[N];
int a[N], n, cnt_num, mn[N << 2], cnt[N << 2], ch[N << 2];
void build(int v = 1, int b = 0, int e = n) {
  if (b + 1 == e) {
    mn[v] = 0;
    cnt[v] = 1;
    return;
  }
  int m = b + e >> 1, l = v << 1, r = l | 1;
  build(l, b, m);
  build(r, m, e);
  mn[v] = min(mn[l], mn[r]);
  cnt[v] = (mn[v] == mn[l] ? cnt[l] : 0) + (mn[v] == mn[r] ? cnt[r] : 0);
}
void push(int v) {
  mn[v << 1 | 0] += ch[v];
  mn[v << 1 | 1] += ch[v];
  ch[v << 1 | 0] += ch[v];
  ch[v << 1 | 1] += ch[v];
  ch[v] = 0;
}
void update(int i, int j, int first, int v = 1, int b = 0, int e = n) {
  if (i >= e || b >= j) return;
  if (i <= b && e <= j) {
    mn[v] += first;
    ch[v] += first;
    return;
  }
  int m = b + e >> 1, l = v << 1, r = l | 1;
  push(v);
  update(i, j, first, l, b, m);
  update(i, j, first, r, m, e);
  mn[v] = min(mn[l], mn[r]);
  cnt[v] = (mn[v] == mn[l] ? cnt[l] : 0) + (mn[v] == mn[r] ? cnt[r] : 0);
}
void add_int(int first, int p) {
  if (!xl[first].size() || !xr[first].size()) return;
  int l = *(xl[first].begin()), r = *(xr[first].begin());
  update(l, r, p);
}
void add_num(int first, int pos) {
  cnt_num -= (xl[first].size() != 0);
  xl[first].insert(pos);
  xr[first].insert(pos);
  cnt_num += (xl[first].size() != 0);
}
void del_num(int first, int pos) {
  cnt_num -= (xl[first].size() != 0);
  xl[first].erase(pos);
  xr[first].erase(pos);
  cnt_num += (xl[first].size() != 0);
}
int get_ans() {
  int blocks = (mn[1] != 0 ? 1 : cnt[1] + 1);
  return cnt_num - blocks;
}
int rmost[N], lmost[N], o[N];
int cmp(int first, int second) { return lmost[first] < lmost[second]; }
int main() {
  int q;
  cin >> n >> q;
  for (int j = 0; j < n; ++j) cin >> a[j];
  for (int j = 0; j < n; ++j) {
    rmost[a[j]] = j;
    cnt[a[j]]++;
  }
  for (int j = n - 1; j >= 0; --j) lmost[a[j]] = j;
  int m = 0;
  for (int j = 0; j < n; ++j) {
    if (j == lmost[a[j]]) {
      o[m++] = a[j];
    }
  }
  sort(o, o + m, cmp);
  int res = n;
  int mx = 0;
  int r = -1;
  for (int i = 0; i < m; ++i) {
    int j = o[i];
    if (lmost[j] < r) {
      mx = max(mx, cnt[j]);
      r = max(r, rmost[j]);
    } else {
      res -= mx;
      mx = cnt[j];
      r = rmost[j];
    }
  }
  res -= mx;
  cout << res << endl;
}
