#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll inf = 2e18;
const ld eps = 1e-13;
using vl = vector<ll>;
using vvl = vector<vl>;
const int block_sz = 3;
struct Segtree {
    struct Node {
        ll min;
    };
    Node null {
        inf
    };
    vector<ll> a;
    vector<Node> t;
    Segtree(vector<ll> &a_) {
        a = a_;
        t.assign((ll)a.size() * 4, null);
        build(0, 0, (ll)a.size());
    }
    Node mergee(Node a, Node b) {
        Node ans;
        ans.min = min(a.min, b.min);
        return ans;
    }
    void build(ll v, ll tl, ll tr) {
        if (tl + 1 == tr) {
            t[v].min = a[tl];
            return;
        }
        ll tm = (tl + tr) / 2;
        build(v*2+1, tl, tm);
        build(v*2+2, tm, tr);
        t[v] = mergee(t[v*2+1], t[v*2+2]);
    }
    void ins(ll v, ll indx, ll val, ll tl, ll tr) {
        if (tl + 1 == tr) {
            t[v].min = val;
            return;
        }
        ll tm = (tl + tr) / 2;
        if (tm > indx) {
            ins(v*2+1, indx, val, tl, tm);
        } else {
            ins(v*2+2, indx, val, tm, tr);
        }
        t[v] = mergee(t[v*2+1], t[v*2+2]);
    }
    Node query(ll v, ll l, ll r, ll tl, ll tr) {
        if (l >= tr || tl >= r) return null;
        if (tl + 1 == tr) return t[v];
        ll tm = (tl + tr) / 2;
        return mergee(query(v*2+1, l, r, tl, tm), query(v*2+2, l, r, tm, tr));
    }
};
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll n, q; cin >> n >> q;
    vector<ll> help(n);
    for (auto &i : help) cin >> i;
    vector<ll> a(n, -1);
    vector<ll> calc(n, -1);
    vector<ll> a_rev(n, -1);
    auto calc_all = [&]() {
        a.assign(n, -1);
        vector<ll> used(n, 0);
        used[0] = 1;
        ll i = 0;
        while (true) {
            bool ok = 0;
            for (ll j = 0; j < n; j++) {
                if (i == j) continue;
                if (help[i] != help[j] && !used[j]) {
                    a[i] = j;
                    used[j] = 1;
//                    cout << "first\n";
//                    cout << i << " " << j << "\n";
                    ok = 1;
                    i = j;
                    break;
                }
            }
            if (!ok) for (ll j = 0; j < n; j++) {
                if (i == j) continue;
                if (!used[j]) {
                    a[i] = j;
                    used[j] = 1;
//                    cout << "second\n";
//                    cout << i << " " << j << "\n";
                    ok = 1;
                    i = j;
                    break;
                }
            }
            if (!ok) break;
        }
//        for (auto &i : a) cout << i << " ";
//        cout << "\n";
    };
    calc_all();
//    for (auto &i : a) cout << i << " ";
//    cout << "\n";
    while (q--) {
        ll tp; cin >> tp;
        if (tp == 2) {
            ll indx; cin >> indx;
            indx--;
            ll anss = 1;
            ll curr = 0;
            while (curr != indx) {
                anss++;
                curr = a[curr];
            }
            cout << anss << "\n";
        } else {
            ll indx; cin >> indx;
            indx--;
            swap(help[indx], help[indx + 1]);
            calc_all();
        }
    }
}
