#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_set>
#include<deque>
using namespace std;
#define int long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
const int maxn = 1e4, mod = 998244353;

int a[maxn], ind[maxn], n;

void per() {
	deque <int> d1, d2;
	int pos = 1;
	for (int i = 0; i < n; ++i) {
		if (sz(d1) && a[d1[0]] == a[i]) d1.pb(i);
		else if (sz(d2) && a[d2[0]] == a[i]) d2.pb(i);
		else if (sz(d1) && sz(d2)) {
			while (sz(d1) && sz(d2)) {
				ind[d1[0]] = pos++;
				ind[d2[0]] = pos++;
				d1.pop_front();
				d2.pop_front();
			}
			if (!sz(d1)) d1.pb(i);
			else d2.pb(i);
		}
		else if (!sz(d1)) d1.pb(i);
		else d2.pb(i);
	}
	while (sz(d1) && sz(d2)) {
		ind[d1[0]] = pos++;
		ind[d2[0]] = pos++;
		d1.pop_front();
		d2.pop_front();
	}
	while (sz(d1)) {
		ind[d1[0]] = pos++;
		d1.pop_front();
	}
	while (sz(d2)) {
		ind[d2[0]] = pos++;
		d2.pop_front();
	}
}

void solve() {
	int q;
	cin >> n >> q;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	per();
	bool f = 0;
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			int x;
			cin >> x;
			--x;
			swap(a[x], a[x + 1]);
			f = 1;
		}
		else {
			if (f) per();
			f = 0;
			int y;
			cin >> y;
			--y;
			cout << ind[y] << "\n";
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
}