#include <bits/stdc++.h>
using namespace std ;
int n , a , m ;
set < int > inuse ;
vector < int > adj [111111] ;
int order [111111] ;
typedef pair < int , int > ii ;
#define P first
#define Q second
int main(){
int i , j, k, l , ans ;
ans= 0 ;
while ( scanf("%d %d %d", &n , &a , &m) != EOF ) { ;
ans = 0 ; inuse.clear() ;
for ( i = 0 ; i < m ; i++)
{
scanf("%d",&order[i]);
adj[ order[i] ].push_back(i) ;
}
int cap = 0 ;
priority_queue < ii , vector < ii > , less <ii> > pq ;
for ( i = 0 ; i < m ; i++){
int x = order[i] ;
set < int > :: iterator fit ;
fit = lower_bound ( inuse.begin() , inuse.end() , x) ;
if( fit != inuse.end())
if( *fit == x )
{
vector < int > :: iterator it ;
it = lower_bound( adj[x].begin() , adj[x].end() , i+1) ;
if( it != adj[x].end())
pq.push(ii(*it,x));
else
pq.push(ii(1e9,x)) ;
// cout << i <<" found "<<x << endl ;
continue ;
}
if ( cap < n ){
inuse.insert(x);
ans++ ; cap++ ;
vector < int > :: iterator it ;
it = lower_bound( adj[x].begin() , adj[x].end() , i+1) ;
if( it != adj[x].end())
pq.push(ii(*it,x)) ;
else
pq.push(ii(1e9,x)) ;
// cout << i << " insert " << x << endl;
continue ;
}
ans++ ;
ii y = pq.top() ; pq.pop() ;
//cout <<x <<" "<< y.P <<" romve->"<<y.Q << endl;
fit = lower_bound( inuse.begin() , inuse.end() , y.Q);
inuse.erase(fit) ;
inuse.insert(x) ;
vector<int> :: iterator it ;
it = lower_bound( adj[x].begin() , adj[x].end() , i+1);
if( it != adj[x].end())
pq.push(ii(*it,x)) ;
else
pq.push(ii(1e9,x)) ;
// cout << i <<" "<< ans << endl ;
}
printf("%d\n",ans) ;
}
return 0 ;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nICBuYW1lc3BhY2Ugc3RkIDsKaW50ICBuICwgYSAsIG0gOwpzZXQgPCBpbnQgPiBpbnVzZSA7CnZlY3RvciA8IGludCA+IGFkaiBbMTExMTExXSA7CmludCBvcmRlciBbMTExMTExXSA7CnR5cGVkZWYgcGFpciA8IGludCAsIGludCA+IGlpIDsKI2RlZmluZSBQIGZpcnN0CiNkZWZpbmUgUSBzZWNvbmQKaW50IG1haW4oKXsKICAgIGludCAgaSAsIGosIGssIGwgLCBhbnMgOwogICAgYW5zPSAwIDsgCiAgIHdoaWxlICggIHNjYW5mKCIlZCAlZCAlZCIsICZuICwgJmEgLCAmbSkgIT0gRU9GICkgeyA7CiAgICBhbnMgPSAwIDsgaW51c2UuY2xlYXIoKSA7CiAgICBmb3IgKCBpID0gMCA7IGkgPCBtIDsgaSsrKQogICAgewogICAgICAgICBzY2FuZigiJWQiLCZvcmRlcltpXSk7CiAgICAgICAgIGFkalsgb3JkZXJbaV0gXS5wdXNoX2JhY2soaSkgOwogICAgfQppbnQgY2FwID0gMCA7CnByaW9yaXR5X3F1ZXVlIDwgaWkgLCB2ZWN0b3IgIDwgaWkgPiAsIGxlc3MgPGlpPiA+IHBxIDsKICAgIGZvciAoIGkgPSAwIDsgaSA8IG0gOyBpKyspewogICAgCiAgICAgICAgaW50IHggPSBvcmRlcltpXSA7CiAgICAgICAgc2V0IDwgaW50ID4gOjogaXRlcmF0b3IgZml0IDsKICAgICAgICBmaXQgPSBsb3dlcl9ib3VuZCAoIGludXNlLmJlZ2luKCkgLCBpbnVzZS5lbmQoKSAsIHgpIDsKICAgICAgICBpZiggZml0ICE9ICBpbnVzZS5lbmQoKSkgIAogICAgICAgIGlmKCAqZml0ID09IHggKQogICAgICAgIHsKICAgICAgICAgICAgdmVjdG9yIDwgaW50ID4gOjogaXRlcmF0b3IgaXQgOwogICAgICAgICAgICBpdCA9IGxvd2VyX2JvdW5kKCBhZGpbeF0uYmVnaW4oKSAsIGFkalt4XS5lbmQoKSAsIGkrMSkgOwogICAgICAgICAgICBpZiggaXQgIT0gYWRqW3hdLmVuZCgpKQogICAgICAgICAgICBwcS5wdXNoKGlpKCppdCx4KSk7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgcHEucHVzaChpaSgxZTkseCkpIDsKICAgICAgICAgICAvLyBjb3V0IDw8IGkgPDwiIGZvdW5kICAiPDx4IDw8IGVuZGwgOwogICAgICAgICAgICBjb250aW51ZSA7CiAgICAgICAgfQoKICAgICAgICBpZiAoIGNhcCA8IG4gKXsKICAgICAgICAgICAgaW51c2UuaW5zZXJ0KHgpOwogICAgICAgICAgICBhbnMrKyA7IGNhcCsrIDsgCiAgICAgICAgICAgIHZlY3RvciA8IGludCA+IDo6IGl0ZXJhdG9yIGl0IDsKICAgICAgICAgICAgaXQgPSBsb3dlcl9ib3VuZCggYWRqW3hdLmJlZ2luKCkgLCBhZGpbeF0uZW5kKCkgLCBpKzEpIDsKICAgICAgICAgICAgaWYoIGl0ICE9IGFkalt4XS5lbmQoKSkKICAgICAgICAgICAgcHEucHVzaChpaSgqaXQseCkpIDsKICAgICAgICAgICAgZWxzZQogICAgICAgICAgICBwcS5wdXNoKGlpKDFlOSx4KSkgOwogICAgICAgICAgIC8vIGNvdXQgPDwgaSA8PCAiIGluc2VydCAiIDw8IHggPDwgZW5kbDsKICAgICAgICAgICAgY29udGludWUgOwogICAgICAgIH0KICAgICAgIGFucysrIDsKICAgICAgIAogICAgICAgaWkgeSA9IHBxLnRvcCgpIDsgcHEucG9wKCkgOwogICAgICAgLy9jb3V0IDw8eCA8PCIgIjw8IHkuUCA8PCIgcm9tdmUtPiI8PHkuUSA8PCBlbmRsOwogICAgICAgZml0ID0gbG93ZXJfYm91bmQoIGludXNlLmJlZ2luKCkgLCBpbnVzZS5lbmQoKSAsIHkuUSk7CiAgICAgICBpbnVzZS5lcmFzZShmaXQpIDsKICAgICAgIGludXNlLmluc2VydCh4KSA7CiAgICAgICB2ZWN0b3I8aW50PiA6OiBpdGVyYXRvciBpdCA7CiAgICAgICBpdCA9IGxvd2VyX2JvdW5kKCBhZGpbeF0uYmVnaW4oKSAsIGFkalt4XS5lbmQoKSAsIGkrMSk7CiAgICAgICBpZiggaXQgIT0gYWRqW3hdLmVuZCgpKQogICAgICAgcHEucHVzaChpaSgqaXQseCkpIDsKICAgICAgIGVsc2UKICAgICAgIHBxLnB1c2goaWkoMWU5LHgpKSA7CiAgICAgIC8vIGNvdXQgPDwgaSA8PCIgIjw8IGFucyA8PCBlbmRsIDsgCiAgICB9CiAgcHJpbnRmKCIlZFxuIixhbnMpIDsKfQogIHJldHVybiAwIDsKfQ==