#include <iostream>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	for (T it : v) {
		out << it << ' ';
	}
	out << '\n';
	return out;
}

#define ll long long

const int MAX = 100'005;
int a[MAX];
int c[MAX];
int to[MAX];
int p[MAX];
int n;

void build() {
	list<int> sk;
	int pr = -1;
	int skc = -1;
	int t = 0;
	for (int i = 0; i < n; i++) {
		if (skc == a[i]) {
			sk.push_back(i);
		}
		else if (skc == -1) {
			if (pr == a[i]) {
				skc = a[i];
				sk.push_back(i);
			}
			else {
				to[i] = t;
				p[t++] = i;
				pr = a[i];
			}
		}
		else {
			to[i] = t;
			p[t++] = i;
			to[sk.front()] = t;
			p[t++] = sk.front();
			sk.pop_front();
			if (sk.size() == 0) {
				skc = -1;
			}
		}
	}
	while (!sk.empty()) {
		to[sk.front()] = t;
		p[t++] = sk.front();
		sk.pop_front();
	}
}
int main()
{
	int q;
	cin >> n >> q;

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

	int t, x;
	for (int i = 0; i < q; i++) {
		cin >> t >> x;
		if (t == 1) {
			int l = to[x - 1];
			int r = to[x];
			if (l > r) {
				swap(l, r);
			}
			if (a[x - 1] != a[x] && (l == 0 || r == 0 || a[p[l - 1]] != a[p[r]] || a[p[r - 1]] != a[p[l]])) {
				swap(a[x - 1], a[x]);
				build();
			}
			else {
				swap(a[x - 1], a[x]);
			}
		}
		else {
			cout << to[x - 1] + 1 << '\n';
		}
	}
}


