#include<bits/stdc++.h>
#include<unordered_map>
#define int long long
#define LL _int128
#define PII pair<int, int>
using namespace std;
int n, m, cnt;
unordered_map<int, int>mp;
int x;
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> m >> n;
for (int i = 1; i <= n; ++i) {
cin >> x;
if (mp.empty()) {
mp[x]++;
cnt++;
}
else if (mp.find(x) == mp.end()) {
if (mp.size() == m) {
mp.erase(mp.begin());
}
cnt++;
mp[x]++;
}
}
cout << cnt << '\n';
return 0;
}