#include <bits/stdc++.h>
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi2,popcnt,lzcnt")
using ll = long long;
using ld = long double;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.erase(s.find_by_order(s.order_of_key(5)));

const int MOD = 998244353;

int add(int a, int b) {
    if (a + b >= MOD) return a + b - MOD;
    return a + b;
}

int sub(int a, int b) {
    if (a < b) return a - b + MOD;
    return a - b;
}

int mul(int a, int b) {
    return a * 1ll * b % MOD;
}

int binPow(int a, int n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return binPow(mul(a, a), n / 2);
    } else {
        return mul(a, binPow(a, n - 1));
    }
}

int inv(int a) {
    return binPow(a, MOD - 2);
}

int f[1000];
int rf[1000];

void build() {
    f[0] = 1;
    rf[0] = inv(1);
    for (int i = 1; i < 1000; i++) {
        f[i] = mul(f[i - 1], i);
        rf[i] = inv(f[i]);
    }
}

int choose(int n, int k) {
    if (n < 0 || k < 0 || n - k < 0) return 0;
    //cout << n << " " << k << " " << mul(f[n], mul(rf[k], rf[n - k])) << "\n";
    return mul(f[n], mul(rf[k], rf[n - k]));
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int t, x;
    vector<int> num(n);
    for (int _ = 0; _ < q; _++) {
        cin >> t >> x;
        x--;
        if (t == 1) {
            swap(a[x], a[x + 1]);
        } else {
            int ind = -1;
            int t1 = -1, t2 = 0, cur = 0;
            for (int j = 0; j < n; j++) {
                if (j == 0 || a[j - 1] == a[j]) {
                    if (cur == 0) {
                        t1 += 2;
                        num[j] = t1;
                    } else {
                        t2 += 2;
                        num[j] = t2;
                    }
                } else {
                    if (t1 < t2) {
                        cur = 0;
                    } else {
                        cur = 1;
                    }
                    if (cur == 0) {
                        t1 += 2;
                        num[j] = t1;
                    } else {
                        t2 += 2;
                        num[j] = t2;
                    }
                }
            }
            if (num[n - 1] >= n) {
                for (int i = n - 1; i >= 0; i--) {
                    if (num[i] > n) {
                        num[i] = i + 1;
                    }
                }
            } else {
                int t = num[n - 1] + 1;
                for (int i = 0; i < n; i++) {
                    if (num[i] > n) {
                        num[i] = t++;
                    }
                }
            }
            cout << num[x] << "\n";
        }
    }
    return 0;
}
//1 3 1 2 2 1 1 2 2 2