#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair<int, int>

using namespace std;

void solve() {
    int n, q; cin >> n >> q;
    vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> num(n);
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            num[i] = cnt1 * 2 + 1;
            cnt1++;
        } else {
            num[i] = cnt2 * 2 + 1;
            cnt2++;
        }
    }
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int x; cin >> x; x--;
            if (a[x] != a[x + 1]) {
                swap(num[x], num[x + 1]);
            }
        } else {
            cout << num[i] << '\n';
        }
    }
}

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