#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

using namespace std;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ff first
#define ss second
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;

constexpr int MOD = (int)1e9 + 7;

struct mint {
    int x;
    mint(int y) {
        if (y >= MOD) y -= MOD;
        if (y < 0) y += MOD;
        x = y;
    }
    mint(ll y) {
        if (y >= MOD) y %= MOD;
        if (y < 0) y += MOD;
        x = y;
    }
    mint operator+(const mint& b) const {
        return x + b.x;
    }
    mint operator-(const mint& b) const {
        return x - b.x;
    }
    mint operator*(const mint& b) const {
        return x * (ll) b.x;
    }
    mint& operator+=(const mint& b) {
        return *this = *this + b;
    }
    mint& operator-=(const mint& b) {
        return *this = *this - b;
    }
    mint& operator*=(const mint& b) {
        return *this = *this * b;
    }
};

struct point {
    ll x, y;

    point operator+(const point& b) const {
        return {x + b.x, y + b.y};
    }
    point operator-(const point& b) const {
        return {x - b.x, y - b.y};
    }
    ll operator*(const point& b) const {
        return x * b.x + y * b.y;
    }
    ll operator%(const point& b) const {
        return x * b.y - y * b.x;
    }
    ll len_sqr() const {
        return x * x + y * y;
    }
    ld len() const {
        return sqrtl(len_sqr());
    }
};

signed main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    vector<int> sa = a;
    sort(all(sa));
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> nxt(n);
    vector<vector<int>> pos(n);
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            int j;
            cin >> j;
            j--;
            swap(a[j], a[j + 1]);
        }
        else {
            int j;
            cin >> j;
            j--;
            queue<int> st;
            st.push(0);
            vector<int> ans(n);
            int placed = 1;
            for (int i = 1; i < n; i++) {
                if (a[st.front()] == a[i]) {
                    st.push(i);
                } else {
                    st.pop();
                    ans[i] = placed++;
                    if (st.empty()) {
                        st.push(i);
                    } else {
                        ans[st.front()] = placed++;
                    }
                }
            }
            st.pop();
            while (st.size()) {
                ans[st.front()] = placed++;
                st.pop();
            }
            cout << ans[j] + 1 << '\n';
        }
    }
}