#include <bits/stdc++.h>

#define MAX_PAGE 1010

using namespace std;

vector<vector<int>> pageReferences;
vector<int> pageReferencesIndex;
vector<int> pages;
unordered_set<int> cache;

int getPageWithFarthestReference() {
   int farthestIndex = INT_MIN;
   for (const int page : cache) {
      // page has no more future references, so remove it
      if (pageReferencesIndex[page] >= pageReferences[page].size()) {
         return page;
      }
      farthestIndex = max(farthestIndex, pageReferences[page][pageReferencesIndex[page]]);
   }
   // otherwise, remove page in the farthest index
   return pages[farthestIndex];
}

int main(){
   int k, v; cin >> k >> v;

   pages.resize(v);
   pageReferences.resize(MAX_PAGE);
   for (int i = 0; i < v; i++) {
      cin >> pages[i];
      pageReferences[pages[i]].push_back(i);
   }
   
   pageReferencesIndex.resize(MAX_PAGE, 0);
   int misses = 0;
   for (int i = 0; i < v; i++) {
      if (!cache.count(pages[i])) {
         bool isCacheFull = cache.size() == k;
         if (isCacheFull) {
            cache.erase(getPageWithFarthestReference());
         }
         misses++;
         cache.insert(pages[i]);
      }
      pageReferencesIndex[pages[i]]++;
   }

   cout << misses << endl;

   return 0;
}