#define _GLIBCXX_DEBUG
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define int long long 


signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int n,q;
    std::cin>>n>>q;

    std::vector<int> a(n);
    for(int i = 0;i < n;i++){
        std::cin>>a[i];
    }

    while(q--){
        int type;
        std::cin>>type;


        if(type == 1){
            int x;
            std::cin>>x;
            x--;
            std::swap(a[x],a[x + 1]);
        }else{
            int y;
            std::cin>>y;
            y--;
            if(y == 0){
                std::cout<<1<<'\n';
                continue;
            }
            int cnt_left = 0;
            int cnt_right = 0;
            int prev = a[0];
            int type_prev = 0;
            cnt_left++;
            int ans = -1;
            

            for(int i = 1;i < n;i++){

                if(a[i] == prev){
                    if(type_prev == 0)cnt_left++;
                    else{cnt_right++;}
                }else{
                    if(cnt_left > cnt_right){
                        cnt_right++;
                        prev = a[i];
                        type_prev = 1;
                    }else{
                        cnt_left++;
                        prev = a[i];
                        type_prev = 0;
                    }
                }
                if(i == y){
                    
                    if(type_prev == 0)ans = cnt_left + cnt_left - 1;
                    else{ans = cnt_right + cnt_right;}
                    
                }
            }
            if(n - y < cnt_right - cnt_left && type_prev == 1){
                ans = y + 1;
            }
            if(n - y < cnt_left - cnt_right && type_prev == 0){
                ans = y + 1;
            }
            assert(ans <= n);
            std::cout<<ans<<std::endl;
        }
    }
}