// Увидеть мир в одной песчинке
// И Космос весь в лесной травинке,
// Вместить в ладони бесконечность
// И в миге мимолетном вечность

#include <iostream>
#include <numeric>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <queue>
#include <stack>
#include <chrono>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
// using int128 = __int128_t;
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll MOD = 998244353;
struct mint {
    ll num;
    mint(ll _num) : num(_num) {}
    mint() {}
    mint operator+(mint y) {
        if (num + y.num >= MOD) return num + y.num - MOD;
        return num + y.num;
    }
    mint operator-(mint y) {
        if (num - y.num < 0) return num - y.num + MOD;
        return num - y.num;
    }
    mint operator*(mint y) {
        return num * y.num % MOD;
    }
    mint pow(int n) {
        mint res = 1;
        mint a = *this;
        for (int i = 0; (1ll << i) <= n; ++i, a = a * a) {
            if ((n >> i) & 1) res = res * a;
        }
        return res;
    }
    mint inv() {
        return (*this).pow(MOD - 2);
    }
    mint operator/(mint y) {
        return num * y.inv().num % MOD;
    }
    void operator+=(mint y) {
        num = (*this + y).num;
    }
    void operator-=(mint y) {
        num = (*this - y).num;
    }
    void operator*=(mint y) {
        num = (*this * y).num;
    }
    void operator/=(mint y) {
        num = (*this / y).num;
    }
};
istream& operator>>(istream &in, mint &x) {
    in >> x.num;
    return in;
}
ostream& operator<<(ostream &out, mint &x) {
    out << x.num;
    return out;
}

// okay, i fucked up >2 hours, but that's okay

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (auto &el : a) cin >> el;
    vector<int> ans(n);
    vector<int> cur;
    auto build = [&]() {
        pair<int, queue<int>> rest;
        for (int i = 0; i < n; ++i) {
            if (!cur.empty() && a[i] == a[cur.back()]) {
                rest.first = a[i];
                rest.second.push(i);
            } else {
                cur.push_back(i);
                if (!rest.second.empty()) {
                    cur.push_back(rest.second.front());
                    rest.second.pop();
                    if (rest.second.empty()) {
                        rest.first = -1;
                    }
                }
            }
        }
        while (!rest.second.empty()) {
            cur.push_back(rest.second.front());
            rest.second.pop();
        }
        for (int i = 0; i < n; ++i) {
            ans[cur[i]] = i + 1;
        }
    };
    build();
    auto rebuild = [&](int x) {
        while (sz(cur) > x) cur.pop_back();
        pair<int, queue<int>> rest;
        for (int i = 0; i < n; ++i) {
            if (!cur.empty() && a[i] == a[cur.back()]) {
                rest.first = a[i];
                rest.second.push(i);
            } else {
                cur.push_back(i);
                if (!rest.second.empty()) {
                    cur.push_back(rest.second.front());
                    rest.second.pop();
                    if (rest.second.empty()) {
                        rest.first = -1;
                    }
                }
            }
        }
        while (!rest.second.empty()) {
            cur.push_back(rest.second.front());
            rest.second.pop();
        }
        for (int i = 0; i < n; ++i) {
            ans[cur[i]] = i + 1;
        }
    };
    for (int i = 0; i < q; ++i) {
        int t, x;
        cin >> t >> x;
        --x;
        if (t == 1) {
            swap(a[x], a[x + 1]);
            rebuild(max(0, x - 1));
        } else {
            cout << ans[x] << '\n';
        }
    }
}


#define LOCAL
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}