#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int INF = 1e18, MOD = 998244353;

int n, q;
vector<int> ind;


void build(vector<int> &a){
    deque<int> st;
    int pred = -1, l = 0, tek = 1;
    while (l != n){
        if (!st.empty() and pred != a[st[0]]){
            ind[st[0]] = tek;
            tek++;
            pred = a[st[0]];
            st.pop_front();
        }else{
            if (pred == a[l]){
                st.pb(l);
                l++;
            }else{
                ind[l] = tek;
                tek++;
                pred = a[l];
                l++;
            }
        }
    }
    for (auto ell: st){
        ind[ell] = tek;
        tek++;
    }
}

void solve(){
    cin >> n >> q;
    vector<int> a(n);
    ind.resize(n);
    for (auto &ell: a) cin >> ell;
    build(a);
    for (int i = 0; i < q; i++){
        int event, x; cin >> event >> x;x--;
        if (event == 1){
            swap(a[x], a[x+1]);
            build(a);
        }else{
            cout << ind[x] << '\n';
        }
    }
}

signed main(){
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int t = 1; //cin >> t;
    while (t--){
        solve();
    }
    return 0;
}
