#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;
            }
           
            std::vector<bool> used(n,false);
            used[0] = true;
            int prev = a[0];
            int cnt = 1;
            int ans = -1;
            int l = 1,r = 1;
            int help = 1;
            bool was = false;

            for(int i = 1;i < n;i++){
                if(l > r){
                    std::swap(l,r);
                }
                if(was){
                    while(help < n && used[help]){
                        help++;
                    }
                     used[help] = true;
                    prev = a[help];
                    if(help == y){
                        ans = cnt;
                    }
                 //   std::cout<<i<<' '<<help<<std::endl;

                    continue;
                }

                while(l < n && (used[l] || a[l] == prev)){
                    l++;
                }
                if(l == n){
                    was = true;
                    while(help < n && used[help]){
                        help++;
                    }
                   // std::cout<<i<<' '<<help<<std::endl;
                     used[help] = true;
                    prev = a[help];
                    if(help == y){
                        ans = cnt;
                    }
                    
                }else{
                    used[l] = true;
                    prev = a[l];
                    std::cout<<i<<' '<<l<<std::endl;
                    if(l == y){
                        ans = cnt;
                    }
                }
                
                cnt++;
             
            }
            std::cout<<ans + 1<<'\n';
        }
    }
}