#define rep(i, a, b) for (int i = a; i < b; ++i) #define per(i, a, b) for (int i = b - 1; i >= a; --i) int vis[maxn]; queue<int> q; int n, m; intmain() { ios::sync_with_stdio(false); while (cin >> n >> m) { // s.clear(); memset(vis, 0, sizeof(vis)); int ans = 0; rep(i, 0, m) {
int a; cin >> a; if (vis[a]) continue; else { if (q.size() == n) { int temp = q.front(); q.pop(); vis[temp] = 0; vis[a] = 1; q.push(a); ans++; } else { q.push(a); vis[a] = 1; ans++; } } } cout << ans << endl; } return0; }