#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7,N = 1e6+9;
typedef long long ll;
int n,m,res;
queue<int>q;
bool a[N];
int main()
{
cin >> n>>m;
for (int i = 1; i <= m; i++)
{
int x;
cin >> x;
if (a[x])continue;
else
{
if (q.size() >= n)
{
a[q.front()] = false;
q.pop();
}
q.push(x);
a[x] = true;
res++;
}
}
cout << res;
return 0;
}