10分求调
#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1000000];
queue<int> q;
queue<int> q1;
int ans;
int main(){
cin >> n >> m;
for (int i = 1; i <= m; i++){
cin >> a[i];
}
for (int i = 1; i <= m; i++){
if (q.size() == 0){
q.push(a[i]);
ans++;
}
else{
int sum = 0;
for (int j = 1; j <= q.size(); j++){
if (a[i] == q.front()) break;
else{
q1.push(q.front());
q.pop();
sum++;
}
}
for (int j = 1;j <= q1.size(); j++){
q.push(q1.front());
q1.pop();
}
if (sum == q.size()){
if (q.size() == n){
q.pop();
q.push(a[i]);
ans++;
}
else if (q.size() < n){
q.push(a[i]);
ans++;
}
}
}
}
cout << ans << endl;
return 0;
}