#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ff first
#define ss second

using namespace std;

vector <int> buildp(int n, vector <int> &a) {
    set <int> s;
    for (int i = 1; i < n; ++i) {
        s.insert(i);
    }
    vector <int> ans(n, 0);
    vector <int> cord(n, 0);
    for (int i = 1; i < n; ++i) {
        int t = *s.begin();
        for (auto v : s) {
            if (a[v] != a[ans[i - 1]]) {
                t = v;
                break;
            }
        }
        ans[i] = t;
        cord[t] = i;
        s.erase(t);
    }
    return cord;
}

void solve() {
    int n, q;
    cin >> n >> q;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector <int> cord = buildp(n, a);
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            --x;
            swap(a[x], a[x + 1]);
            cord = buildp(n, a);
        } else {
            int i;
            cin >> i;
            cout << cord[i - 1] + 1 << '\n';
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int t = 1;
    while (t--) solve(), cout << '\n';
}