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

using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("Ofast,unroll-loops,O3")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

void upd(vector<int>& a, vector<int>& ans, vector<int>& val, int s, int p) {
    int n = a.size();

    vector<char> used(n, 0);

    for (int i = 0; i < s; ++i) {
        used[val[i]] = 1;
    }

    for (int i = s; i < n; ++i) {
        int res = -1;
        for (int j = 0; j < n; ++j) {
            if (!used[j] && a[j] != p) {
                res = j;
                break;
            }
        }
        if (res == -1) {
            for (int j = 0; j < n; ++j) {
                if (!used[j]) {
                    ans[j] = i;
                    val[i++] = j;
                }
            }
            break;
        }
        ans[res] = i;
        val[i] = res;
        used[res] = 1;
        p = a[res];
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

//    random_device rnd;
//    mt19937 gen(rnd());
//    uniform_int_distribution<> dis(0, n - 1);
//    uniform_real_distribution<> dis1(0, 1);

    int n, q;
    cin >> n >> q;
    vector<int> a(n);

    for (int& i : a) {
        cin >> i;
    }

    vector<int> ans(n);
    vector<int> val(n);

    upd(a, ans, val, 0, 0);

    while (q--) {
        int t;
        cin >> t;

        if (t == 1) {
            int x;
            cin >> x;
            --x;
            swap(a[x], a[x + 1]);
            int s = min(ans[x], ans[x + 1]);
            int p = (s ? a[val[s - 1]] : 0);
            upd(a, ans, val, s, p);
        }
        else {
            int y;
            cin >> y;
            --y;
            cout << ans[y] + 1 << "\n";
        }
    }
}
