#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif // LOCAL

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

void smart_solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (auto& el : a) {
        cin >> el;
        --el;
    }

    vector<int> ps(n);
    auto calc_ps = [&]() -> void {
        fill(ps.begin(), ps.end(), -1);
        int prv = -1;
        int i = 0;
        for (; i < n; ++i) {
            int j = 0;
            while (j < n && (a[j] == prv || ps[j] != -1)) {
                ++j;
            }
            if (j == n) {
                break;
            }
            ps[j] = i;
            prv = a[j];
        }
        for (int j = 0; j < n; ++j) {
            if (ps[j] == -1) {
                ps[j] = i++;
            }
        }
    };

    calc_ps();
    while (q--) {
        int qt, i;
        cin >> qt >> i;
        --i;
        if (qt == 1) {
            if (a[i] == a[i + 1]) {
                continue;
            }
            swap(a[i], a[i + 1]);
            if (ps[i] + 1 != ps[i + 1]) {
                swap(ps[i], ps[i + 1]);
                continue;
            }
            calc_ps();
        } else {
            cout << ps[i] + 1 << "\n";
        }
    }
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int times = 1;
//    cin >> times;
    while (times--) {
        smart_solve();
    }
    return 0;
}
