#include<bits/stdc++.h>
using namespace std;
int main() {
int m, n;
cin >> m >> n;
int cnt = 0;
queue<int> a;//存文章
queue<int> b;//缓存
for (int i = 0; i < n; i++) {
int d;
cin >> d;
a.push(d);
}
b.push(a.front());
a.pop();
cnt++;
for (int r = 0; r < n - 1; r++) {
int d = 0;
int c = b.size();
for (int i = 0; i < c; i++) {
if (a.front() == b.front()) {
d = 1;
}
b.push(b.front());
b.pop();
}
if (d == 1) {
a.pop();
} else {
cnt++;
if (b.size() < m) {
b.push(a.front());
} else {
b.pop();
b.push(a.front());
}
a.pop();
}
}
cout << cnt;
return 0;
}