#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const ll mod = 998244353;

ll bp(ll a, ll b) {
    if (b == 0) return 1;
    ll ans = 1;
    if (b % 2) ans = a;
    ll tp = bp(a, b / 2);
    ans = ans * tp % mod * tp % mod;
    return ans;
}

/*void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }

}*/

vector<vector<ll>> g;
vector<ll> tin, tout, sz;
ll timer = 1;

void calc(ll v, ll p) {
    sz[v] = 1;
    for (auto u : g[v]) {
        if (u != p) {
            calc(u, v);
            sz[v] += sz[u];
        }
    }
}

void solve() {
    ll n,k;
    cin >> n >> k;
    vector<ll> x(n);
    for (ll i = 0; i < k; i++) {
        cin >> x[i];
        x[i]--;
    }
    g.resize(n), tin.resize(n), tout.resize(n), sz.resize(n);
    vector<ll> par(n);
    for (ll i = 1; i < n; i++) {
        ll p;
        cin >> p;
        --p;
        par[i] = p;
        g[p].push_back(i);
        g[i].push_back(p);
    }
    calc(0, -1);
    ll ans = bp(2, sz[x[0]] - 1);
    for (auto u : g[x[0]]) {
        if (u == par[u]) continue;
        ans -= bp(2, sz[u]) - 1;
        ans %= mod;
    }
    cout << (ans % mod + mod + bp(2, sz[x[0]] - 1) - (sz[x[0]] != 1) + mod) % mod;
}


void solveA() {
    int n,q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    vector<int> pos(n), num(n);
    int cur1 = 0, cur2 = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            pos[i] = cur1++;
            num[i] = 1;
        }
        else {
            pos[i] = cur2++;
            num[i] = 2;
        }
    }
    while (q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int x;
            cin >> x;
            --x;
            if (a[x] == a[x + 1]) continue;
            swap(pos[x], pos[x + 1]);
            swap(num[x], num[x + 1]);
            swap(a[x], a[x+1]);
        }
        else {
            int idx;
            cin >> idx;
            --idx;
            cout << pos[idx] * 2 + 1 + (num[idx] != a[0]) << "\n";
        }
    }
}

signed main() {
    solveA();
}