#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
using ll = long long;

mt19937 rnd(52);
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
#endif
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> b(n);
    for (int i = 0; i < q; i++) {
        int x, j;
        cin >> x >> j;
        j--;
        if (x == 1) {
            swap(a[j], a[j+1]);
        } else {
            deque<int> left;
            vector<int> order(n);
            int ans = 0;
            if (j == 0) {
                ans = 0;
            }
            int uk = 0;
            for (int i = 1; i < n; i++) {
                if (left.size() and a[left[0]]!=order[uk]) {
                    //cout << i << "F\n";
                    order[++uk] = left[0];
                    if (left[0] == j) {
                        ans = uk;
                        //break;
                    }
                    left.pop_front();
                }
                if (a[i]!=order[uk]) {
                    order[++uk] = i;
                    if (i == j) {
                        ans = uk;
                        //break;
                    }
                } else {
                    //cout << i << "G\n";
                    left.push_back(i);
                }
            }
            cout << ans+1 << endl;
        }
    }
    return 0;
}