#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 main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout << fixed << setprecision(17);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int t, x;
    for (int _ = 0; _ < q; _++) {
        cin >> t >> x;
        x--;
        if (t == 1) {
            swap(a[x], a[x + 1]);
        } else {
            int t1 = -1, t2 = 0, cur = 0;
            int fl = 0;
            for (int j = n - 1; j >= 0; j--) {
                if (j != n - 1 && a[j] != a[j + 1]) {
                    break;
                }
                if (j == x) {
                    cout << j + 1 << " ";
                    fl = 1;
                    break;
                }
            }
            if (!fl) {
                for (int j = 0; j < n; j++) {
                    if (j == 0 || a[j - 1] == a[j]) {
                        if (cur == 0) {
                            t1 += 2;
                            if (j == x) {
                                cout << t1 << " ";
                            }
                        } else {
                            t2 += 2;
                            if (j == x) {
                                cout << t2 << " ";
                            }
                        }
                    } else {
                        if (t1 < t2) {
                            cur = 0;
                        } else {
                            cur = 1;
                        }
                        if (cur == 0) {
                            t1 += 2;
                            if (j == x) {
                                cout << t1 << " ";
                            }
                        } else {
                            t2 += 2;
                            if (j == x) {
                                cout << t2 << " ";
                            }
                        }
                    }
                }
            }
        }
    }

    return 0;
}