#ifndef LOCAL
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<vector>
#pragma GCC optimize("avx2")
#endif

#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;

using i128 = __int128;
using ll = long long;
using ld = long double;

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

template<typename T, typename V>
using table = gp_hash_table<T, V>;

const int inf = 2e9 + 7;
const ll INF = 4e18 + 7;
const int maxn = 500 + 7;
const int MOD = 998244353;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        v[i]--;
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            swap(v[x - 1], v[x]);
        } else {
            int y;
            cin >> y;
            --y;
            vector<int> used(n);
            deque<int> dq;
            int cnt = 1;
            for (int i = 0; i < n; ++i) {
                dq.push_back(i);
                if (v[dq.front()] != v[dq.back()]) {
                    used[dq.front()] = cnt++;
                    dq.pop_front();
                    if (v[dq.front()] != v[dq.back()]) {
                        used[dq.back()] = cnt++;
                        dq.pop_back();
                    }
                }
            }
            for (auto c: dq) used[c] = cnt++;
            cout << used[y] << "\n";
        }
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin>>t;
    while (t--) solve();
}
