#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

//#define int long long
#define all(arr) arr.begin(), arr.end()
#define rall(arr) arr.rbegin(), arr.rend()

typedef long long ll;
typedef long double ld;
typedef __int128 lll;

mt19937_64 rnd(0);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){
    int n, q;
    cin >> n >> q;
    vector<int> arr(n);
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    while (q--){
        int t;
        cin >> t;
        if (t == 1){
            int x;
            cin >> x;
            swap(arr[x - 1], arr[x]);
        } else {
            vector<int> p;
            p.push_back(0);
            int last = 0, left = 1;
            vector<int> used(n);
            while (p.size() < n){
                left = max(last + 1, left);
                while (left < n && arr[left] == arr[last]){
                    left++;
                }
                if (left == n){
                    int idx = last + 1;
                    while (idx < n){
                        if (!used[idx]){
                            p.push_back(idx);
                        }
                        idx++;
                    }
                    continue;
                }
                if (left == last + 1){
                    p.push_back(left);
                    used[left] = 1;
                    last++;
                }else if (used[last + 1]){
                    p.push_back(left);
                    last++;
                    while (last < left && used[last]){
                        last++;
                    }
                    if (last != left){
                        p.push_back(last);
                    }
                    used[left] = 1;
                    left++;
                    used[last] = 1;
                } else {
                    p.push_back(left);
                    p.push_back(last + 1);
                    used[left] = 1;
                    last++;
                    used[last] = 1;
                    left++;
                }
            }
            int y;
            cin >> y;
            cout << find(all(p), y - 1) - p.begin() + 1 << '\n';
        }
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(10);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--){
        solve();
        cout << '\n';
    }
    return 0;
}
