#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back

//#define int long long

vector<int> a;
int n;
const int INF= 1e9 + 7;

set<pii > s;
vector<int> ind;

void updt() {
    for (int i = 0; i < n; i++) {
        ind[i] = 0;
    }
    ind[0] = 1;
    int lst = a[0];
    bool f = true;
    int cnt = 2;
    while (f) {
        f = false;
        for (int i = 0; i < n; i++) {
            if (!ind[i] && lst != a[i]) {
                f = true;
                ind[i] = cnt++;
                lst = a[i];
                break;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (!ind[i])ind[i] = cnt++;
    }
}
void solve() {
    int q; cin >> n >> q;
    a.resize(n);
    ind.resize(n);
    set<int> v1, v2;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 1)v1.insert(i);
        else v2.insert(i);
    }
    updt();
    while (q--) {
        int t, x; cin >> t >> x;
        x--;
        if (t == 1) {
            swap(a[x], a[x + 1]);
            swap(ind[x], ind[x + 1]);
        } else {
            cout << ind[x] << '\n';
        }
    }

}


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