#include <bits/stdc++.h>
using namespace std;
template <class T>
class compare {
 public:
  bool operator()(pair<T, T> &x, pair<T, T> &y) {
    if (x.first == y.first) {
      return x.second > y.second;
    }
    return x.first > y.first;
  }
};
long long power(long long a, int b) {
  long long po = 1;
  while (b) {
    if (b & 1) po *= a;
    a *= a;
    b >>= 1;
  }
  return po;
}
template <class T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) {
  return {a.first + b.first, a.second + b.second};
}
template <class T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) {
  return {a.first - b.first, a.second - b.second};
}
template <class T>
pair<T, T> operator*(const pair<T, T> &a, const pair<T, T> &b) {
  return {a.first * b.first, a.second * b.second};
}
template <class T>
pair<T, T> operator%(const pair<T, T> &a, const pair<T, T> &b) {
  return {a.first % b.first, a.second % b.second};
}
template <class T, class U>
pair<T, T> operator+(const pair<T, T> &a, const U &b) {
  return {a.first + b, a.second + b};
}
template <class T, class U>
pair<T, T> operator*(const pair<T, T> &a, const U &b) {
  return {a.first * b, a.second * b};
}
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(long long N, int pos) { return (bool)(N & (1LL << pos)); }
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  int q;
  cin >> q;
  int ara[n];
  int pos[200005];
  int cnt[200005];
  memset(cnt, 0, sizeof cnt);
  memset(pos, -1, sizeof pos);
  for (int i = 0; i < n; i++) {
    cin >> ara[i];
    pos[ara[i]] = i;
    cnt[ara[i]]++;
  }
  int last = 0;
  int maxi = 0;
  int from = 0;
  int ans = 0;
  for (int i = 0; i < n;) {
    from = i;
    maxi = 0;
    while (i < n and i <= last) {
      last = max(last, pos[ara[i]]);
      maxi = max(maxi, cnt[ara[i]]);
      i++;
    }
    last = i;
    ans += (i - from - maxi);
  }
  cout << ans << "\n";
  return 0;
}
