#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 5e3 + 11;
const int mod = 998244353;

signed main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1);
    int mxval = 0;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    while (q--) {
        int t, x; cin >> t >> x;
        if (t == 1) swap (a[x], a[x + 1]);
        else {
            vector<int>T(n + 1);
            T[1] = 1;
            int last = 1;
            for (int i = 2; i <= n; ++i) {
                deque<int> v;
//                cout << i << ' ' << last <<'\n';
                v.push_back(i);
                int nxt = i + 1;
                int len = (a[i] == a[i - 1]);
                if (!len) {
                    T[i] = last + 1, ++last;
                    continue;
                }

                while (nxt <= n && len) {
                    if (a[nxt] == a[i - 1]) {
                        ++len, v.push_back(nxt);
                    }
                    else {
                        --len;
                        T[nxt] = last + 1;
                        ++last;
                        T[v[0]] = last + 1;
                        ++last;
                        v.pop_front();
                    }
                    ++nxt;
                }
                if (len) {
                    for (auto it : v) {
                        T[it] = last + 1, ++last;
                    }
                    break;
                }
                i = nxt - 1;
            }
            cout << T[x] << '\n';
        }
    }

}

