// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

// #define int long long
#define all(x) x.begin(), x.end()

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")

const int MOD = 998244353;
const int MAXN = 1e6 + 1;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q, type, ind, y;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < q; i++) {
        cin >> type;
        if (type == 1) {
            cin >> ind;
            ind--;
            swap(a[ind], a[ind + 1]);
        } else {
            cin >> y;
            y--;
            vector<int> for_later = {};
            int ind_begin = 0;
            int last_not_checked = 1;
            int cur_ind = 0;
            int cur_num = 0;
            while (cur_ind != y) {
//                cout << "cur_ind = " << cur_ind << endl;
                cur_num++;
                if (ind_begin != for_later.size() && a[for_later[ind_begin]] != a[cur_ind]) {
                    cur_ind = for_later[ind_begin];
                    ind_begin++;
                    continue;
                }
                while (last_not_checked < n && a[last_not_checked] == a[cur_ind]) {
                    for_later.push_back(last_not_checked++);
                }
                if (last_not_checked == n) {
                    cur_ind = for_later[ind_begin];
                    ind_begin++;
                    continue;
                } else {
                    cur_ind = last_not_checked++;
                }
            }
            cout << cur_num + 1 << endl;
        }
    }
    return 0;
}
