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

#define all(a) a.begin(), a.end()

#define int long long

using namespace __gnu_pbds;
using namespace std;

template<class T>
using ord_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;

const int inf = 1e9;
const ll INF = 1e16;

const int mod = 998'244'353;


ord_set<pii> st;
int n;
vector<int> num;
void procc(vector<int>& a) {
    num.assign(n, -1);
    int indR = 1;
    int curr = 1;
    for (int i = 0; i < n; ++i) {
        if (i != indR - 1 && num[i] != -1) continue;
        indR = max(indR, i + 1);
        if (num[i] == -1) {

            num[i] = curr++;
        }
        if (indR >= n) continue;
        else {
            while (indR < n && a[i] == a[indR]) {
                ++indR;
            }
            if (indR >= n) continue;
            num[indR] = curr++;
            ++indR;
        }

    }
}

void solve() {
    int q, cmd, x;
    cin >> n >> q;

    vector<int> a(n);
    for (auto& val : a) {
        cin >> val;
    }

    procc(a);
    while (q--) {
        cin >> cmd >> x;
        if (cmd == 1) {
            --x;
            swap(a[x], a[x + 1]);
            procc(a);
        } else {
            cout << num[x - 1] << '\n';
        }
    }
}

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

    int t = 1;
    //cin >> t;

    while (t--) {
        solve();
    }
}