#include <bits/stdc++.h>
//#define int long long

using namespace std;
const int INF = 1e9;

struct node {
    int mx, mn;
};

vector <node> t;

void build(vector <int> &a, int v, int tl, int tr) {
    if (tl + 1 == tr) {
        t[v].mx = a[tl];
        t[v].mn = a[tl];
        return;
    }

    int tm = (tl + tr) / 2;
    build(a, v * 2, tl, tm);
    build(a, v * 2 + 1, tm, tr);

    t[v].mx = max(t[v * 2].mx, t[v * 2 + 1].mx);
    t[v].mn = min(t[v * 2].mn, t[v * 2 + 1].mn);
}

void update(int v, int tl, int tr, int i, int x) {
    if (i < tl || i >= tr) {
        return;
    }

    if (tl + 1 == tr) {
        t[v].mn = INF;
        t[v].mx = -INF;
        return;
    }

    int tm = (tl + tr) / 2;
    update(v * 2, tl, tm, i, x);
    update(v * 2 + 1, tm, tr, i, x);
    t[v].mx = max(t[v * 2].mx, t[v * 2 + 1].mx);
    t[v].mn = min(t[v * 2].mn, t[v * 2 + 1].mn);
}

int get(int v, int tl, int tr, int x) {
    if (tl + 1 == tr) {
        if (t[v].mn < x || t[v].mx > x) {
            return tl;
        }
        else {
            return INF;
        }
    }

    int left = INF;
    int right = INF;

    int tm = (tl + tr) / 2;
    if (t[v * 2].mn < x || t[v * 2].mx > x) {
        left = get(v * 2, tl, tm, x);
    }
    if (t[v * 2 + 1].mn < x || t[v * 2 + 1].mx > x) {
        right = get(v * 2 + 1, tm, tr, x);
    }

    return min(left, right);
}

int32_t main() {
    ios::sync_with_stdio(false);
    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];
    }

    t.resize(n * 4);

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

        if (tt == 1) {
            int x;
            cin >> x;
            x--;

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

            vector <int> w(n, -1);

            build(a, 1, 0, n);
            int timer = 1;
            queue <int> s;
            s.push(0);

            while (!s.empty()) {
                int cur = s.front();
                s.pop();
                w[cur] = timer++;
                update(1, 0, n, cur, INF);

                int x = get(1, 0, n, a[cur]);

                if (x != INF) {
                    s.push(x);
                }
            }

            for (int i = 0; i < n; ++i) {
                if (w[i] == -1) {
                    w[i] = timer++;
                }
            }

            cout << w[y] << "\n";
        }
    }

    return 0;
}