#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

using namespace __gnu_pbds;
using namespace std;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<int> get(vector<int> a) {
    int n = a.size();
    int lst = -1;
    vector<int> nm(n);
    int cr = 1;
    queue<int> q;
    for (int j = 0; j < n; ++j) {
        if (a[j] != lst) {
            nm[j] = cr++;
            lst = a[j];
            if (!q.empty() && a[q.front()] != lst) {
                nm[q.front()] = cr++;
                lst = a[q.front()];
                q.pop();
            }
        } else q.push(j);
    }
    while (!q.empty()) {
        nm[q.front()] = cr++;
        q.pop();
    }
    return nm;
}

signed main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    vector<int> nm(n);
    int d = 1, e = 1;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 1) {
            nm[i] = e;
            e++;
        } else {
            nm[i] = d;
            d++;
        }
    }
    d--;e--;
    for (int _ = 0; _ < q; ++_) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            x--;
            if (a[x] != a[x + 1]) {
                swap(nm[x], nm[x + 1]);
                swap(a[x], a[x + 1]);
            }
        } else {
            int y;
            cin >> y;
            y--;
            if (a[y] == 2) {
                if (a[0] == 2) {
                    if (e >= nm[y] - 1) {
                        cout << nm[y] + nm[y] - 1 << '\n';
                    } else {
                        cout << e + e + 1 + nm[y] - e - 1 << '\n';
                    }
                } else {
                    if (e >= nm[y]) {
                        cout << nm[y] + nm[y] << '\n';
                    } else {
                        cout << e + e + nm[y] - e << '\n';
                    }
                }
            } else {
                if (a[0] == 1) {
                    if (d >= nm[y] - 1) {
                        cout << nm[y] + nm[y] - 1 << '\n';
                    } else {
                        cout << d + d + 1 + nm[y] - d - 1 << '\n';
                    }
                } else {
                    if (e >= nm[y]) {
                        cout << nm[y] + nm[y] << '\n';
                    } else {
                        cout << d + d + nm[y] - d << '\n';
                    }
                }
            }
        }
    }
}