#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using u128 = __int128_t;
using ull = unsigned long long;
using ld = long double;

#define dbg(x) cerr << #x << " = " << x << endl

const ll LINF = 2e18;
const int INF = 1e9 + 10;
const int LOG = 30;

const int N = 2e5 + 10;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int &i : a) cin >> i;
    for (int &i : a) i--;

    while (q--) {
        int tp;
        cin >> tp;
        if (tp == 1) { 
            int x;
            cin >> x;
            x--;
            swap(a[x], a[x + 1]);
        } else {
            int y;
            cin >> y;
            y--;
            queue<int> q;
            vector<int> ind(n);
            int moves = 0;
            int i = 0;
            int prev = -1;
            while (!q.empty() || i < n) {
                if ((!q.empty() && prev != a[q.front()]) || i == n) {
                    int lst = q.front();
                    q.pop();
                    ind[lst] = moves;
                    prev = a[lst];
                    moves++;
                } else {
                    if (a[i] == prev) {
                        q.push(i);
                        i++;
                    } else {
                        ind[i] = moves;
                        prev = a[i];
                        i++;
                        moves++;
                    }
                }
            }
            cout << ind[y] + 1 << "\n";
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
