#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
ll n , q , k , x , v;
int a[N];
int main(){
cin >> n >> q;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
while(q--){
cin >> k;
if(k == 1){
cin >> x >> v;
a[x] = v;
} else {
cin >> x;
int left = 0 , right = 0;
for(int i = 1; i <= x - 1; i++){
if(a[i] > a[x]){
left++;
}
}
for(int i = x; i <= n; i++){
if(a[i] < a[x]){
right++;
}
}
cout << x - left + right << endl;
}
}
return 0;
}