#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Os")
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll maxn=2e5+10, maxm=3e3+10, lg=7, mod=1e9+7, inf=1e18;

int n,m,a[maxn],x,y,cnt[maxn],line[maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>m;
	int emp=n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		int p=a[i]-cnt[a[i]]++;
		emp-=(p>0 && !line[p]++);
	}
	while(m--){
		cin>>x>>y;
		int p=a[x]-cnt[a[x]]--+1;
		emp+=(p>0 && !--line[p]);
		a[x]=y;
		int q=a[x]-cnt[a[x]]++;
		emp-=(q>0 && !line[q]++);
		cout<<emp<<'\n';
	}
	
	return 0;
}
