#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
#include <random>
#include <unordered_map>
#include <deque>
typedef long long ll;
typedef long double ld;
using namespace std;
void solve() {
	ll n, q; cin >> n >> q;
	vector<ll>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	while (q--) {
		ll t, l; cin >> t >> l; l--;
		if (t == 1) {
			swap(a[l], a[l + 1]);
		}
		else {
			vector<ll>ans;
			deque<ll>q;
			for (int i = 0; i < n; i++) {
				if (ans.size()==0 || a[ans.back()] != a[i]) {
					ans.push_back(i);
					if (q.size()) {
						ans.push_back(q.front()); q.pop_front();
						
					}
				}
				else {
					q.push_back(i);
				}
			}
			while (q.size()) {
				ans.push_back(q.front());
				q.pop_front();
			}
			for (int i = 0; i < n; i++){
				if (ans[i] == l) {
					cout << i + 1 << endl;
					break;
				}
			}
		}
	}
}
int main()
{
	cin.tie(nullptr)->sync_with_stdio(false);
	cout.tie(nullptr)->sync_with_stdio(false);

	ll _T = 1;//cin>>_T;
	while (_T--)
		solve();
}