#include <bits/stdc++.h>

#define MAX_PAGE 1010

using namespace std;

vector<int> pageReferencesCount;
vector<int> pages;
unordered_set<int> cache;

int getPageWithLeastReferenceCount() {
    int count = INT_MAX, leastReferencedPage = -1;
    for (const int page : cache) {
        // page has no more future references, so remove it
        if (pageReferencesCount[page] <= 0) {
            return page;
        }
        if (pageReferencesCount[page] < count) {
            count = pageReferencesCount[page];
            leastReferencedPage = page;
        }
    }
    // otherwise, remove page with the least number of future references
    return leastReferencedPage;
}

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

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

    cout << misses << endl;

    return 0;
}