#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#define int int64_t
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define pii pair<int, int>
#define vpi vector<pii>
#define vb vector<bool>
#define umap unordered_map
using namespace std;
//using namespace __gnu_pbds;
//mt19937 rng(333);
//template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//template<class T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
int mini(vi& p, int tar) {
	int n= p.size();
	int D[2];
	int c=0;
	D[0] = 0; D[1] = 0;
	int prev=-1;
	bool vis[n];
	for (int i=0; i<n; ++i) vis[i] = false;
	while (1) {
		//cout << c << ' ' << D[0] << ' ' << D[1] << endl;
		while (D[c&1] < n) {
			if (p[D[c&1]] != prev && !vis[D[c&1]]) {
				//cout << "setting " << D[c&1]+1 << " as " << c+1 << endl;
				prev = p[D[c&1]];
				vis[D[c&1]] = true;
				if (D[c&1] == tar) return c+1;
				c++;
				break;
			}
			D[c&1]++;
		}
		if (D[c&1] == n) {
			int x = 1-(c&1);
			while (1) {
				if (!vis[D[x]]) {
					c++;
					if (D[x] == tar) {
						return c;
					}
				}
				D[x]++;
			}
		}
	}
}
void solve() {
	int n, q; cin >> n >> q;
	vi p(n, 0); for (int i=0; i<n; ++i) cin >> p[i];
	int t, x;
	for (int i=0; i<q; ++i) {
		cin >> t >> x;
		if (t == 1) {
			swap(p[x-1], p[x]);
		} else {
			cout << mini(p, x-1) << '\n';
		}
	}
}
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int t=1; //cin >> t;
	while (t--) solve();
	return 0;
}
