#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, 0);
    int c1 = 0, c2 = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 1) num[i] = c1;
        else num[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]) {
                swap(a[x], a[x + 1]);
                swap(num[x], num[x + 1]);
            }
        } else {
            int x; cin >> x; x--;
            if (a[x] == 1) {
                if (a[0] == 1) {
                    if (c2 >= num[x]) cout << num[x] * 2 + 1 << " ";
                    else cout << x + 1 << " ";
                } else {
                    if (c2 >= num[x] + 1) cout << num[x] * 2 + 2 << " ";
                    else cout << x + 1 << " ";
                }
            } else {
                if (a[0] == 2) {
                    if (c1 >= num[x]) cout << num[x] * 2 + 1 << " ";
                    else cout << x + 1 << " ";
                } else {
                    if (c1 >= num[x] + 1) cout << num[x] * 2 + 2 << " ";
                    else cout << x + 1 << " ";
                }
            }
        }
    }
}

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();
}