#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}
const int N = 2e5 + 7;
int n, q, m, T[N], fst[N], lst[N], cnt[N];
int eq[N];
vector<int> G[N];
bool vis[N];
int sm, mx;
void dfs(int v) {
  vis[v] = true;
  sm += cnt[v];
  mx = max(mx, cnt[v]);
  for (auto u : G[v]) {
    if (!vis[u]) {
      dfs(u);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> T[i];
    lst[T[i]] = i;
    if (fst[T[i]] == 0) fst[T[i]] = i;
    m = max(m, T[i]);
    cnt[T[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    int a = fst[T[i]], b = lst[T[i]];
    eq[b + 1]--;
    eq[a + 1]++;
  }
  for (int i = 2; i <= n; i++) {
    eq[i] += eq[i - 1];
    if (eq[i] > 0) {
      G[T[i]].push_back(T[i - 1]);
      G[T[i - 1]].push_back(T[i]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    if (vis[i]) continue;
    mx = sm = 0;
    dfs(i);
    ans += sm - mx;
  }
  cout << ans << "\n";
  return 0;
}
