#include <bits/stdc++.h>

using namespace std;
int n, q;
vector <int> a;
vector <int> times;
vector <bool> used;

void calc(vector <int>& timer) {
    fill(used.begin(), used.end(), false);
    int l = 0, r = 0;
    int cnt = 0;
    int t = 0;
    while (true) {
        //cout << l  + 1 << ' ' << r + 1 << ' ' << t << '\n';
        if (r == n) {
            while (l < n) {
                if (!used[l]) {
                    timer[l] = t;
                    t++;
                }
                l++;
            }
            break;
        }
        if (l == n) {
            while (r < n) {
                if (!used[r]) {
                    timer[r] = t;
                    t++;
                }
                r++;
            }
            break;
        }
        if (cnt == 0) {
            if (l > 0 || used[l]) {
                while (l < n && (a[l] == a[r] || used[l])) {
                    l++;
                }
            }
            if (l == n) {
                while (r < n) {
                    if (!used[r]) {
                        timer[r] = t;
                        t++;
                    }
                    r++;
                }
                break;
            }
            timer[l] = t;
            used[l] = true;
            t++;
            cnt = 1 - cnt;
    }   else {
            while (r < n && (a[l] == a[r] || used[r])) {
                r++;
            }
            if (r == n) {
                while (l < n) {
                    if (!used[l]) {
                        timer[l] = t;
                        t++;
                    }
                    l++;
                }
                break;
            }
            timer[r] = t;
            used[r] = true;
            t++;
            cnt = 1 - cnt;
    }
    }
}

signed main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);
    cin >> n >> q;
    a.resize(n);
    used.resize(n);
    times.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        if (a[i] != 0) {
            a[i] = 1;
        }
    }
    if (a[0] == 1) {
        for (int i = 0; i < n; i++) {
            a[i] = 1 - a[i];
        }
    }
    vector <int> nums(n);
    int f1 = 0, f2 = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0) {
            nums[i] = f1;
            f1++;
    }   else {
            nums[i] = f2;
            f2++;
    }
    }
    for (int i = 0; i < q; i++) {
        int kind;
        cin >> kind;
        if (kind == 1) {
            int pos;
            cin >> pos;
            if (a[pos - 1] != a[pos]) {
                swap(nums[pos - 1], nums[pos]);
                swap(a[pos - 1], a[pos]);
            }
    }   else {
            int y;
            cin >> y;
            y--;
            if (a[y] == 0) {
                if (nums[y] <= f2) {
                    cout << nums[y] * 2 + 1 << '\n';
            }   else {
                    cout << f2 + nums[y] + 1 << '\n';
            }
        }   else {
                if (nums[y] <= f1 - 1) {
                    cout << nums[y] * 2 + 2 << '\n';
            }   else  {
                    cout << f1 + nums[y] + 1 << '\n';
            }
        }
    }
    }
}
