#pragma GCC optimize("O3,unroll-loops")
#include <vector>
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>

#define $(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;
using dbl = long double;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        b--;
        if (a == 1) swap(v[b], v[b + 1]);
        else {
            int clr = -1;
            deque<int> st;
            vector<int> t(n);
            int T = 0;
            for (int i = 0; i < n; i++) {
                if (st.size() == 0 && clr != v[i]) {
                    t[i] = T++;
                    clr = v[i];
                } else {
                    if (st.size() != 0) {
                        if (clr == v[i]) {
                            st.push_back(i);
                        } else {
                            t[i] = T++;
                            t[st.front()] = T++;
                            st.pop_front();
                        }
                    } else {
                        st.push_back(i);
                    }
                }
            }
            for (auto i : st) t[i] = T++;
            cout << t[b] + 1 << "\n";
        }
    }
}