#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <immintrin.h>

using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,bmi,popcnt")


// #define double long double
#define int long long
#define endl "\n"
#define ordered_set  tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

constexpr int MOD = 998244353;
constexpr int INF = 2e9;
constexpr int K = 3;
constexpr int P = 31;
constexpr double eps = 1e-9;
constexpr int MOD1 = (1ll << 61) - 1;

inline int pls(int a, int b) {
    if (a + b >= MOD1) return a + b - MOD1;
    return a + b;
}

inline int mns(int a, int b) {
    return pls(a, MOD1 - b);
}

inline int umn(int a, int b) {
    __int128 c = __int128(a) * b;
    return pls(c & MOD1, c >> 61);
}

int binpow(int n, int k, int mod) {
    if (!k) return 1;
    if (k & 1) return n * binpow(n, k ^ 1, mod) % mod;
    int c = binpow(n, k >> 1, mod);

    return c * c % mod;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            cin >> i;
            i--;
            swap(a[i], a[i + 1]);
        } else {
            int y;
            cin >> y;
            y--;
            vector<int> cur = {0};
            if (y == 0) {
                cout << 1 << endl;
                continue;
            }
            deque<int> bilo;
            bool found = false;
            for (int i = 1; i < n; i++) {
                while (!bilo.empty() && a[cur.back()] != a[bilo.front()]) {
                    if (y == bilo.front()) {
                        cout << cur.size() + 1 << endl;
                        found = true;
                        break;
                    }
                    cur.push_back(bilo.front());
                    bilo.pop_front();
                }
                if (found) break;
                if (a[i] == a[cur.back()]) {
                    bilo.push_back(i);
                } else {
                    if (y == i) {
                        cout << cur.size() + 1 << endl;
                        break;
                    }
                    cur.push_back(i);
                }
            }
            if (!found) {
                while (!bilo.empty()) {
                    if (bilo.front() == y) {
                        cout << cur.size() + 1 << endl;
                        break;
                    }
                    cur.push_back(bilo.front());
                    bilo.pop_front();
                }
            }
        }
    }
}
