#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <map>



using namespace std;

typedef long long ll;

mt19937 gen;

int rnd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(gen);
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout.precision(30);

	int n, q;
	cin >> n >> q;

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

	for (int i = 0; i < q; ++i) {
		int t;
		cin >> t;

		if (t == 1) {
			int qi;
			cin >> qi;
			--qi;
			swap(a[qi], a[qi + 1]);
		}

		vector<int> ord(n);
		vector<bool> us(n, false);

		int l = 0, r = 0;
		int ls = -1;
		for (int i = 0; i < n; ++i) {
			while (l < n && us[l]) ++l;

			if (a[l] != ls) {
				ord[i] = l;
				us[l] = true;
			}
			else {
				while (r < n && (us[r] || a[r] == ls)) {
					++r;
				}
				if (r < n && a[r] != ls) {
					ord[i] = r;
					us[r] = true;
				}
				else {
					ord[i] = l;
					us[l] = true;
				}
			}
			ls = a[ord[i]];
		}

		if (t == 2) {
			int qi;
			cin >> qi;
			--qi;
			for (int ps = 0; ps < n; ++ps) {
				if (ord[ps] == qi) {
					cout << ps + 1 << '\n';
				}
			}
		}

	}


}
