#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 200005
using namespace std;
int n,m,ans,a[MN],c[MN],now[MN];
int main(){
	scanf("%d%d",&n,&m);ans=n;int x,y;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);c[a[i]]++;
		if(a[i]-c[a[i]]>=0&&!(now[a[i]-c[a[i]]]++))ans--;
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		if(a[x]-c[a[x]]>=0&&!(--now[a[x]-c[a[x]]]))ans++;
		c[a[x]]--;a[x]=y;c[a[x]]++;
		if(a[x]-c[a[x]]>=0&&!(now[a[x]-c[a[x]]]++))ans--;
		printf("%d\n",ans);
	}
}

