#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <random>

using namespace std;
//mt19937 rnd(1908);
int inf = 1e9;
struct Node {
	int min, color;
	Node() {}
	Node(int m, int c) : min(m), color(c) {}
};
Node merge(Node a, Node b) {
	Node now;
	if (b.min < a.min) {
		now.color = b.color;
		now.min = b.min;
	}
	else {
		now.color = a.color;
		now.min = a.min;
	}
	return now;
}
struct SegTree {
	int n;
	vector<Node> tree;
	void build(int v, int l, int r, vector<int>& a) {
		if (v == 1) {
			tree.resize(r << 2);
			n = r;
		}
		if (l + 1 == r) {
			tree[v].min = a[l];
			tree[v].color = l;
			return;
		}
		int mid = (l + r) >> 1;
		build(v << 1, l, mid, a);
		build((v << 1) + 1, mid, r, a);
		tree[v] = merge(tree[v << 1], tree[(v << 1) + 1]);
	}
	void update(int v, int l, int r, int i, int x) {
		if (l + 1 == r) {
			tree[v].min = x;
			return;
		}
		int mid = (l + r) >> 1;
		if (i < mid) {
			update(v << 1, l, mid, i, x);
		}
		else {
			update((v << 1) + 1, mid, r, i, x);
		}
		tree[v] = merge(tree[v << 1], tree[(v << 1) + 1]);
	}
	Node get(int v, int l, int r, int ql, int qr) {
		if (qr <= l || r <= ql) return Node(inf, n);
		if (ql <= l && r <= qr) return tree[v];
		int mid = (l + r) >> 1;
		return merge(get(v << 1, l, mid, ql, qr), get((v << 1) + 1, mid, r, ql, qr));
	}
};

/*struct Tree {
	int n;
	struct Vertex {
		int p, sp, len_sp, tin, tout, sz = 1, up, d = 0;
		vector<int> gr;
	};
	vector<Vertex> vertexes;
	SegTree HLD_array;
	int root = 0;
	int t = 0;
	void pred_dfs(int v) {
		vertexes[v].up = v;
		for (int u : vertexes[v].gr) {
			if (u != vertexes[v].p) {
				vertexes[u].d = vertexes[v].d + 1;
				vertexes[u].p = v;
				if (vertexes[v].len_sp == vertexes[vertexes[v].sp].len_sp) {
					vertexes[u].len_sp = vertexes[v].len_sp * 2 + 1;
					vertexes[u].sp = vertexes[vertexes[v].sp].sp;
				}
				else {
					vertexes[u].sp = v;
					vertexes[u].len_sp = 1;
				}
				pred_dfs(u);
				vertexes[v].sz += vertexes[u].sz;
			}
		}
	}
	void weight_dfs(int v) {
		vertexes[v].tin = ++t;
		if (vertexes[v].gr.size()) {
			int best = vertexes[v].gr[0];
			for (int u : vertexes[v].gr) {
				if (u != vertexes[v].p && vertexes[best].sz < vertexes[u].sz) {
					best = u;
				}
			}
			vertexes[best].up = vertexes[v].up;
			weight_dfs(best);
			for (int u : vertexes[v].gr) {
				if (u != vertexes[v].p && u != best) {
					weight_dfs(u);
				}
			}
		}
		vertexes[v].tout = t;
	}
	void build(int N, int r, vector<vector<int>>& gr) {
		root = r;
		n = N;
		vertexes.resize(n);
		vertexes[root].p = root;
		vertexes[root].sp = root;
		vertexes[root].len_sp = 0;
		for (int i = 0; i < n; ++i) {
			vertexes[i].gr = gr[i];
		}
		pred_dfs(root);
	}
	int la(int v, int d) {
		while (vertexes[v].d > d) {
			if (vertexes[vertexes[v].sp].d > d) {
				v = vertexes[v].sp;
			}
			else {
				v = vertexes[v].p;
			}
		}
		return v;
	}
	int lca(int v, int u) {
		if (vertexes[v].d > vertexes[u].d) swap(v, u);
		u = la(u, vertexes[v].d);
		while (u != v) {
			if (vertexes[u].sp != vertexes[v].sp) {
				v = vertexes[v].sp;
				u = vertexes[u].sp;
			}
			else {
				v = vertexes[v].p;
				u = vertexes[u].p;
			}
		}
		return v;
	}
	void build_HLD(vector<long long>& a) {
		weight_dfs(root);
		vector<long long> on_tin(n);
		for (int i = 0; i < n; ++i) {
			on_tin[vertexes[i].tin] = a[i];
		}
		HLD_array.build(1, 0, n, on_tin);
	}
};*/

/*struct SparceTable {
	int n;
	vector<vector<long long>> d;
	vector<int> log;
	void build(vector<long long>& a) {
		n = a.size();
		log.resize(n + 1);
		for (int k = 0; (1 << k) <= n; ++k) {
			log[(1 << k)] = 0;
		}
		for (int i = 2; i <= n; ++i) {
			if (!log[i]) log[i] = log[i - 1];
		}
		d.resize(log[n] + 1, vector<long long>(n));
		for (int i = 0; i < n; ++i) {
			d[0][i] = a[i];
		}
		for (int k = 1; k < d.size(); ++k) {
			for (int i = 0; i < n - (1 << k) + 1; ++i) {
				d[k][i] = min(d[k - 1][i], d[k - 1][i + (1 << k)]);
			}
		}
	}
	long long get_min(int l, int r) {
		int lg = log[r - l];
		return min(d[lg][l], d[lg][r - (1 << lg)]);
	}
};

struct Kurevo {
	Kurevo* l = nullptr, * r = nullptr;
	long long sz = 1;
	long long val;
	long long sum;
	long long y = rnd();
	Kurevo(long long x) : val(x), sum(x) {}
};

long long get_sum(Kurevo* t) {
	if (!t) return 0;
	return t->sum;
}
long long get_sz(Kurevo* t) {
	if (!t) return 0;
	return t->sz;
}
void upd(Kurevo* t) {
	if (!t) return;
	t->sum = get_sum(t->l) + t->sum * get_sum(t->r);
	t->sz = get_sz(t->l) + 1 + get_sz(t->r);
}

Kurevo* merge(Kurevo* t1, Kurevo* t2) {
	if (!t1) return t2;
	if (!t2) return t1;
	if (t1->y > t2->y) {
		t1->r = merge(t1->r, t2);
		upd(t1);
		return t1;
	}
	else {
		t2->l = merge(t1, t2->l);
		upd(t2);
		return t2;
	}
}
pair<Kurevo*, Kurevo*> split(Kurevo* t, int k) {
	if (!t) return make_pair(nullptr, nullptr);
	if (get_sz(t->l) < k) {
		auto q = split(t->r, k - get_sz(t->l) - 1);
		t->r = q.first;
		upd(t);
		return make_pair(t, q.second);
	}
	else {
		auto q = split(t->l, k);
		t->l = q.second;
		upd(t);
		return make_pair(q.first, t);
	}
}*/

int main() {
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		--a[i];
	}
	int t;
	int x;
	int y;
	while (q--) {
		cin >> t;
		if (t == 1) {
			cin >> x;
			--x;
			swap(a[x], a[x + 1]);
		}
		else {
			cin >> y;
			--y; vector<vector<int>> colors(n);
			vector<int> ind_color(n);
			vector<int> now_array(n, inf);
			for (int i = 0; i < n; ++i) {
				colors[a[i]].push_back(i);
			}
			for (int i = 0; i < n; ++i) {
				if (colors[i].size()) {
					now_array[i] = colors[i][0];
				}
			}
			SegTree Color;
			Color.build(1, 0, n, now_array);
			vector<int> queue(n);
			++ind_color[a[0]];
			if (ind_color[a[0]] < (int)colors[a[0]].size()) {
				Color.update(1, 0, n, a[0], colors[a[0]][ind_color[a[0]]]);
			}
			else {
				Color.update(1, 0, n, a[0], inf);
			}
			int color_last = a[0];
			for (int i = 1; i < n; ++i) {
				Node now = merge(Color.get(1, 0, n, 0, color_last), Color.get(1, 0, n, color_last + 1, n));
				if (now.min == inf) {
					queue[i] = colors[color_last][ind_color[color_last]];
					++ind_color[color_last];
					if (ind_color[color_last] < colors[color_last].size()) {
						Color.update(1, 0, n, color_last, colors[color_last][ind_color[color_last]]);
					}
					else {
						Color.update(1, 0, n, color_last, inf);
					}
				}
				else {
					queue[i] = colors[now.color][ind_color[now.color]];
					++ind_color[now.color];
					if (ind_color[now.color] < colors[now.color].size()) {
						Color.update(1, 0, n, now.color, colors[now.color][ind_color[now.color]]);
					}
					else {
						Color.update(1, 0, n, now.color, inf);
					}
					color_last = now.color;
				}
			}
			vector<int> pos(n);
			for (int i = 0; i < n; ++i) {
				pos[queue[i]] = i;
			}
			cout << pos[y] + 1 << '\n';
		}
	}
}