#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using uc = unsigned char;
using ull = unsigned long long;
using ul = unsigned long;
using i128 = __int128_t;
using u128 = __uint128_t;

struct dataf {
    vector<int> mapping;
    vector<int> from;
    vector<int> to;
};

inline void solve(ostringstream& os) {
    int n, q;
    cin >> n >> q;

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

    auto rebuild = [&]() -> dataf {
        queue<pair<int, int>> que; // color, pos
        vector<int> order;
        order.reserve(n);
        int cur_top = -1;

        for (int i = 0; i < n; ++i) {
            while (!que.empty() && que.front().first != cur_top) {
                cur_top = que.front().first;
                order.emplace_back(que.front().second);
                que.pop();
            }

            if (a[i] != cur_top) {
                order.emplace_back(i);
                cur_top = a[i];
            }

            else {
                que.emplace(a[i], i);
            }
        }

        while (!que.empty()) {
            order.emplace_back(que.front().second);
            que.pop();
        }

        vector<int> mapping(n);
        for (int i = 0; i < n; ++i) {
            mapping[order[i]] = i;
        }

        return dataf{mapping, {}, {}};
    };

    bool correct = true;
    auto dt = rebuild();
    int chill = n;
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;

        int ind;
        cin >> ind;
        --ind;

        if (t == 1) {
            if (a[ind] == a[ind + 1]) continue;
            correct = false;
            swap(a[ind], a[ind + 1]);
            chill = min(chill, ind);
        }

        else {
            if (!correct && ind >= chill) {
                dt = rebuild();
                correct = true;
                chill = n;
            }

            cout << dt.mapping[ind] + 1 << '\n';
        }
    }
    exit(0);

}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ostringstream os;

    solve(os);

    cout << os.str();
    // exit(0);
}