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

using namespace std;
using namespace __gnu_pbds;

// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update<>>

const int MOD = 998244353;
const int INF = 1e18;


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

    vector<int> a(n, 0);

    vector<deque<int> > dt(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        dt[a[i]].push_back(i);
    }

    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            x--;
            if (a[x] == a[x + 1]) {
                continue;
            }
            int c1 = a[x];
            int c2 = a[x + 1];
            swap(a[x], a[x + 1]);
            int i1 = lower_bound(all(dt[c1]), x) - dt[c1].begin();
            int i2 = lower_bound(all(dt[c2]), x + 1) - dt[c2].begin();
            dt[c1][i1] = x + 1;
            dt[c2][i2] = x;
        } else {
            int y;
            cin >> y;
            y--;
            auto b = dt;
            int nw = 0;
            int cnt = 1;
            b[a[0]].pop_front();
            while (nw != y) {
                int mn = n;
                for (int i = 0; i < n; i++) {
                    if (i == a[nw] || b[i].size() == 0) {
                        continue;
                    }
                    mn = min(mn, b[i].front());
                }
                if (mn == n) {
                    mn = b[a[nw]].front();
                }
                cnt++;
                nw = mn;
                b[a[mn]].pop_front();
            }
            cout << cnt << endl;
        }
    }
}


signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

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

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