#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

int inf = (int)1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 100;
// int inf = (int)1000 * 1000 * 1000 + 100;

/*
#pragma optimize("O3")
#pragma optimize("avx,avx2,bmi,bmi2")
*/

mt19937_64 rnd(228);

void print(vector <int> a) {
    for (int i = 0; i < a.size(); i ++) {
        cout << a[i] << " ";
    }
    cout << '\n';
}

int mod = 998244353;

int umn(int a, int b) {
    return (a * b) % mod;
}

int umn(int a, int b, int c) {
    return umn(a, umn(b, c));
}

int umn(int a, int b, int c, int d) {
    return umn(a, umn(b, c, d));
}

int umn(int a, int b, int c, int d, int e) {
    return umn(a, umn(b, c, d, e));
}

int bin_pow(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 0) {
        return bin_pow(umn(a, a), x / 2);
    }
    return umn(a, bin_pow(a, x - 1));
}

int del(int a, int b) {
    return umn(a, bin_pow(b, mod - 2));
}

int fact(int n) {
    int c = 1;
    for (int i = 1; i <= n; i ++) {
        c = umn(c, i);
    }
    return c;
}

int cnk(int n, int k) {
    return del(fact(n), umn(fact(k), fact(n - k)));
}

int norm(int x) {
    x %= mod;
    x += mod;
    x %= mod;
    return x;
}

void solve() {
    int n, q;
    cin >> n >> q;
    vector <int> a(n);
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
    }

    vector <int> ans(n);

    while (q --) {
        int type;
        cin >> type;
        if (type == 1) {
            int x;
            cin >> x;
            x --;
            swap(a[x], a[x + 1]);
        }
        else {
            int y;
            cin >> y;
            y --;

            int tek = 1;
            deque <int> d;
            int last = 0;
            for (int i = 0; i < n; i ++) {
                // cout << i << " " << d.size() << " " << last << '\n';
                if (a[i] == last) {
                    d.push_back(i);
                    continue;
                }
                if (last == 0) {
                    d.push_back(i);
                    last = a[i];
                    continue;
                }
                if (d.size() == 0) {
                    d.push_back(i);
                    last = a[i];
                    continue;
                }
                if (d.size() == 1) {
                    ans[d.front()] = tek;
                    tek ++;
                    d.clear();
                    d.push_back(i);
                    last = a[i];
                    continue;
                }
                ans[d.front()] = tek;
                tek ++;
                ans[i] = tek;
                tek ++;
                d.pop_front();
            }
            for (int i = 0; i < d.size(); i ++) {
                ans[d[i]] = tek;
                tek ++;
            }

            // for (int i = 0; i < n; i ++) {
            //     cout << a[i] << " ";
            // }
            // cout << '\n';

            cout << ans[y] << '\n';
        }
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

    int _ = 1;
    // cin >> _;
    while (_ --) {
        solve();
    }
}