#include <bits/stdc++.h>
#define int long long

using namespace std;
const int MOD = 998'244'353;

ostream& operator<<(ostream& out, vector<int> v) {
    for (auto el : v) {
        out << el << " ";
    }
    return out << "\n";
}
istream& operator>>(istream& in, vector<int>& v) {
    for (auto& el : v) {
        in >> el;
    }
    return in;
}

int n;
vector<int> a(n);
vector<int> big(n), cnt(n);
vector<int> ans(n);

void calc() {
    queue<int> q;
    int x = 0;
    int num = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] == x) {
            q.push(i);
            big[i] = x;
            cnt[i] = q.size();
            continue;
        }
        if (q.size() == 0) {
            x = a[i];
            ans[i] = num++;
            big[i] = x;
        }
        else {
            ans[i] = num++;
            ans[q.front()] = num++;
            q.pop();
            big[i] = x;
            cnt[i] = q.size();
        }
    }
    while (!q.empty()) {
        ans[q.front()] = num++;
        q.pop();
    }
}

void solve() {
    int m;
    cin >> n >> m;
    a.resize(n);
    big.resize(n);
    cnt.resize(n);
    ans.resize(n);
    cin >> a;
    calc();
    while (m--) {
        int t = 0;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            swap(a[x], a[x - 1]);
            calc();
        }
        else {
            int y;
            cin >> y;
            cout << ans[y - 1] << "\n";
        }
    }
}

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

    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
