#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const long long MOD = 998244353;

void type2(vector<int> v, int y, map<int, int> mp) {
    y--;
    int n = v.size();
    vector<int> q(v.size());
    q[0] = 1;
    int a = mp[1], b = mp[2];
    int aa = 1, bb = 1;
    if (v[0] == 1) {
        bb = 2;
    } else {
        aa = 2;
    }
    if (a < b) {
        for (int i = 0; i < n; i++) {
            if (v[i] == 1) {
                q[i] = aa;
                aa += 2;
            } else {
                if (a == 0) {
                    q[i] = bb;
                    bb++;
                } else {
                    q[i] = bb;
                    bb += 2;
                    a--;
                }
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            if (v[i] == 2) {
                q[i] = bb;
                bb += 2;
            } else {
                if (b == 0) {
                    q[i] = aa;
                    aa++;
                } else {
                    q[i] = aa;
                    aa += 2;
                    b--;
                }
            }
        }
    }
    cout << q[y];
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> v(n);
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        mp[v[i]]++;
    }
    for (int i = 0; i < q; i++) {
        int t; cin >> t;
        if (t == 1) {
            int x; cin >> x;
            swap(v[x - 1], v[x]);
        } else {
            int y; cin >> y;
            type2(v, y, mp);
            cout << '\n';
        }
    }
}
