#pragma GCC optimize("O3")

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

#define int long long
#define db long double
#define MX LLONG_MAX
#define MN LLONG_MIN
#define gcd __gcd
#define lcm(a, b) (a / gcd(a, b) * b)

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

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

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

    int n, q;
    cin >> n >> q;

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

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

        if (type == 1) {
            int pos;
            cin >> pos;
            pos--;

            swap(a[pos], a[pos + 1]);
        } else {
            int k;
            cin >> k;
            k--;

            int last = -1;
            queue<pair<int, int>> q; // type pos

            int pos = 0, ans = -1;
            for (int i = 0; i < n && ans == -1; i++) {
                if (!q.empty()) {
                    auto [t, j] = q.front();

                    if (t != last) {
                        q.pop();
                        if (j == k) ans = i;
                        last = t;
                        continue;
                    }
                }

                while (pos < n && a[pos] == last) { q.push({a[pos], pos}); pos++; }
                if (pos != n) {
                    if (pos == k) ans = i;
                    last = a[pos++];
                } else {
                    auto [t, j] = q.front();
                    q.pop();
                    if (j == k) ans = i;
                }
            }

            cout << ans + 1 << "\n";
        }
    }
}
