#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
using vl = __int128_t;
using ld = long double;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
const ll mod = 998244353;
vector<vector<ll>> g;
vector<ll> sz, x;
ll ans = 0;
ll pw(ll a, ll b) {
    ll r = 1;
    while (b) {
        if (b & 1) r = r * a % mod;
        a = a * a % mod, b >>= 1;
    }
    return r;
}
void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n), p(n);
    ll c2 = 0, c1 = 0;
    for (ll& x : a) cin >> x, c2 += (x == 2), c1 += (x == 1);
    ll x = 0;
    for (ll i = 0; i < n; i++) {
        if (a[i] == 1) {
            p[i] = x;
            c2--;
            if (c2>0) x += 2;
            else x++;
        }
    }
    x = 1;
    for (ll i = 0; i < n; i++) {
        if (a[i] == 2) {
            p[i] = x;
            c1--;
            if (c1>0) x += 2;
            else x++;
        }
    }
    for (ll i = 0; i < q; i++) {
        ll tp;
        cin >> tp;
        if (tp == 1) {
            ll x;
            cin >> x;
            x--;
            if (a[x] != a[x + 1]) {
                swap(p[x], p[x + 1]);
                swap(a[x], a[x + 1]);
            }
        } else {
            ll y;
            cin >> y;
            y--;
            cout << p[y] + 1 << '\n';
        }
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
