#include <bits/stdc++.h>
#define all(v) begin(v), end(v)
#define dbg(x) "[" #x " = " << x << "]"
#define ii pair<int, long long>
#define fi first
#define se second
#define siz(v) (int)(v).size()
#define lli pair<long long, int>
#define BIT(x, i) (((x) >> (i)) & 1)
using namespace std;
const int infINT = 1e9 + 1323, mod = 1e18 + 7;
const long long inf = 1e18 + 123123;
template<class X, class Y> bool minimize(X &x, const Y &y){return x > y ? x = y, 1: 0;}
template<class X, class Y> bool maximize(X &x, const Y &y){return x < y ? x = y, 1: 0;}
void add(long long &a, const long long &b){
a += b;
if (a >= mod) a -= mod;
}
void sub(long long &a, const long long &b){
a -= b;
if (a < 0) a += mod;
}
long long mul(const long long &a, const long long &b){
return 1LL * a * 1LL * b % mod;
}
struct fenwickTree{
int n;
vector<int > bit;
fenwickTree(int _n = 0): n(_n){
bit.assign(n + 1, 0);
}
void update(int pos, const int &delta){
for(; pos <= n; pos += pos & -pos) bit[pos] += delta;
}
void update(int l, int r, const int &delta){
update(l, +delta);
update(r + 1, -delta);
}
int get(int pos){
int sum = 0;
for(; pos > 0; pos ^= pos & -pos) sum += bit[pos];
return sum;
}
};
const int MAXN = 1e6 + 6;
int numVal, numQuery, val[MAXN];
fenwickTree bit;
void input(){
cin >> numVal >> numQuery;
for(int i = 1; i <= numVal; i++) cin >> val[i];
}
void add(int L, int R, const int &delta){
if (L > R) swap(L, R);
bit.update(L + 1, R - 1, +delta);
}
void add(const int &pos, const int &delta){
bit.update(pos, pos, +delta);
if (pos > 1) add(val[pos - 1], val[pos], +delta);
if (pos < numVal) add(val[pos], val[pos + 1], +delta);
}
void solve(){
bit = fenwickTree(MAXN);
for(int i = 1; i < numVal; i++){
add(val[i], val[i + 1], +1);
}
for(int q = 1; q <= numQuery; q++){
int type;
cin >> type;
if (type == 1){
int pos, newval; cin >> pos >> newval;
add(pos, -1);
val[pos] = newval;
add(pos, +1);
}else{
int pos; cin >> pos;
cout << bit.get(pos) << '\n';
}
}
}
bool M1;
bool M2;
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task "GAME"
if (fopen(task".in", "r")){
freopen(task".in", "r", stdin);
freopen(task".out", "w", stdout);
}
input();
solve();
cerr << (&M2 - &M1) / 1048576 << " mb\n";
cerr << (1.0 * clock()) / CLOCKS_PER_SEC << ".s\n";
}