#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
using namespace std;
using ll = long long;
using ld = long double;
#define endl '\n'
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, q; cin >> n >> q; vector<int> v(n);
	for (auto& i : v) cin >> i;
	vector<int> t(n, 0); t[0] = 0;
	int lst = v[0]; deque<int> dq; int pt = 1;
	for (int i = 1; i < n; i++) {
		int fl = 0;
		while (pt < n) {
			if (v[pt] != lst) {
				t[pt] = i; lst = v[pt]; fl = 1;
				if (dq.size()) {
					t[dq[0]] = i + 1; lst = v[dq[0]]; dq.pop_front(); i++; fl = 2;
				}
				pt++; break;
			}
			dq.push_back(pt); pt++;
		}
		if (fl == 2) continue;
		if (fl == 1) {
			continue;
		}
		for (auto el : dq) {
			t[el] = i; i++;
		}
	}
	while (q--) {
		int tp, p; cin >> tp >> p;
		if (tp == 1) {
			if (v[p - 1] == v[p]) continue;
			swap(v[p - 1], v[p]);
			t.assign(n, 0); t[0] = 0;
			lst = v[0]; dq.clear(); pt = 1;
			for (int i = 1; i < n; i++) {
				int fl = 0;
				while (pt < n) {
					if (v[pt] != lst) {
						t[pt] = i; lst = v[pt]; fl = 1;
						if (dq.size()) {
							t[dq[0]] = i + 1; lst = v[dq[0]]; dq.pop_front(); i++; fl = 2;
						}
						pt++; break;
					}
					dq.push_back(pt); pt++;
				}
				if (fl == 2) continue;
				if (fl == 1) {
					continue;
				}
				for (auto el : dq) {
					t[el] = i; i++;
				}
			}
			//for (auto el : v) cout << el << " ";
			//cout << endl;
			//for (auto el : t) cout << el << " ";
			//cout << endl << endl;
		}
		else {
			//cout << p << " check\n";
			//for (auto el : t) cout << el << " ";
			//cout << endl;
			cout << t[p - 1] + 1 << endl;
		}
	}
	return 0;
}
