#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);
    vector<int> cnt1(n, 0), cnt2(n, 0);
    int c1 = 0, c2 = 0;
    for (int i = 0; i < n; i++) {
        cnt1[i] = c1;
        cnt2[i] = c2;
        if (a[i] == 1) c1++;
        else c2++;
    }
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int x; cin >> x; x--;
            if (a[x] != a[x + 1]) {
                if (a[x] == 1) {
                    cnt1[x + 1]--;
                    cnt2[x + 1]++;
                } else {
                    cnt1[x + 1]++;
                    cnt2[x + 1]--;
                }
                swap(a[x], a[x + 1]);
            }
        } else {
            int x; cin >> x; x--;
            if (a[x] == 1) {
                if (a[0] == 1) {
                    if (cnt2[x] < cnt1[x]) cout << x + 1 << '\n';
                    else cout << cnt1[x] * 2 + 1 << '\n';
                } else {
                    if (cnt2[x] < cnt1[x] + 1) cout << x + 1 << '\n';
                    else cout << cnt1[x] * 2 + 2 << '\n';
                }
            } else {
                if (a[0] == 1) {
                    if (cnt1[x] < cnt2[x] + 1) cout << x + 1 << '\n';
                    else cout << cnt2[x] * 2 + 2 << '\n';
                } else {
                    if (cnt1[x] < cnt2[x]) cout << x + 1 << '\n';
                    else cout << cnt2[x] * 2 + 1 << '\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();
}