#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define len(x) (int)x.size()
#define start auto st = clock()
#define finish auto fin = clock(); cerr << 1000 * (fin - st) / (ld)CLOCKS_PER_SEC << endl
const ll mod2 = 998244353;

using namespace std;

void print(vector<int> &a) {
    for (auto x : a) cout << x << ' ';
    cout << '\n';
}

void print(vector<ll> &a) {
    for (auto x : a) cout << x << ' ';
    cout << '\n';
}

// #define mtask
// #define int ll

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < q; ++i) {
        int tp;
        cin >> tp;
        if (tp == 1) {
            int x;
            cin >> x;
            swap(a[x - 1], a[x]);
        }
        else {
            int x;
            cin >> x;
            --x;
            vector<bool> used(n);
            bool fl = true;
            int ptr1 = 0;
            int ptr2 = 0;
            int lst = -1;
            int ind = 0;
            for (int j = 0; j < n; ++j) {
                if (fl) {
                    while (ptr1 < n && (used[ptr1] || a[ptr1] == lst)) ++ptr1;
                    if (ptr1 == n) {
                        ++ind;
                        while (used[ptr2]) {
                            ++ptr2;
                        }
                        if (ptr2 == x) {
                            cout << ind << '\n';
                            break;
                        }
                        used[ptr2] = true;
                        lst = a[ptr2];
                    }
                    else {
                        ++ind;
                        if (ptr1 == x) {
                            cout << ind << '\n';
                            break;
                        }
                        used[ptr1] = true;
                        lst = a[ptr1];
                        fl = false;
                    }
                }
                else {
                    while (ptr2 < n && (used[ptr2] || a[ptr2] == lst)) ++ptr2;
                    if (ptr2 == n) {
                        ++ind;
                        while (used[ptr1]) {
                            ++ptr1;
                        }
                        if (ptr1 == x) {
                            cout << ind << '\n';
                            break;
                        }
                        used[ptr1] = true;
                        lst = a[ptr1];
                    }
                    else {
                        ++ind;
                        if (ptr2 == x) {
                            cout << ind << '\n';
                            break;
                        }
                        used[ptr2] = true;
                        lst = a[ptr2];
                        fl = true;
                    }
                }
                // cout << ptr1 << ' ' << ptr2 << '\n';
            }
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
#ifdef mtask
    int t;
    cin >> t;
    while (t--)
#endif
        solve();
}