#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  long long solve(vector<int> &a) {
    unordered_map<int, int> right, sizes;
    for (int i = 0; i < a.size(); ++i) {
      right[a[i]] = i;
      sizes[a[i]]++;
    }
    int cnt = 0;
    int i = 0, j = 0;
    int r = right[a[0]];
    int mostFreq = sizes[a[0]];
    while (j < a.size()) {
      while (j < r) {
        r = max(r, right[a[++j]]);
        mostFreq = max(mostFreq, sizes[a[j]]);
      }
      cnt += j - i + 1 - mostFreq;
      ++j;
      i = j;
      if (j < a.size()) {
        r = right[a[j]];
        mostFreq = sizes[a[j]];
      }
    }
    return cnt;
  }
};
int main() {
  Solution sol;
  int n, q;
  cin >> n >> q;
  vector<int> a(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  cout << sol.solve(a) << endl;
  return 0;
}
