#include<iostream>
#include<algorithm>
#define N 50001
#define re register
using namespace std;
long long n,q,c,a[N],b[N];
int main(){
scanf("%lld%lld",&n,&q);
for(re int i=1;i<=n;i++) scanf("%lld",&a[i]);
for(re int i=1;i<=q;i++){
scanf("%lld",&c);
if(c==1){
scanf("%lld",&c);
scanf("%lld",&a[c]);
}
else{
scanf("%lld",&c);
for(re int j=1;j<=n;j++) b[j]=a[j];
for(re int j=1;j<=n;j++)
for(re int k=j;k>=2;k--)
if(b[k]<b[k-1]){
if(k==c) c--;
else if(k-1==c) c++;
int t1=b[k-1];
b[k-1]=b[k];
b[k]=t1;
}
printf("%lld\n",c);
}
}
return 0;
}