#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <queue>
#include <iomanip>
#define int long long
using namespace std;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, q; cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	while (q--) {
		int t; cin >> t;
		int x; cin >> x;
		if (t == 1) {
			swap(a[x], a[x - 1]);
		}
		else {
			vector<int> res(n);
			vector<bool> fl(n);
			fl[0] = 1;
			res[0] = 0;
			int col = a[0];
			bool p = 0;
			for (int j = 1; j < n && p == 0; j++) {
				for (int i = 0; i < n; i++) {
					if (col != a[i] && fl[i] == 0) {
						fl[i] = 1;
						p = 1;
						res[j] = i;
						col = a[i];
						break;
					}
				}
				if (p == 0) {
					for (int w = 0; w < n; w++) {
						if (fl[w] == 0) {
							res[j] = w;
							j++;
						}
					}
				}
				p = 0;
			}
			int ans = 0;
			for (int i = 0; i < n; i++) {
				if (res[i] == x - 1) {
					ans = i + 1;
				}
			}
			cout << ans << '\n';
		}
	}
} 