#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<iomanip>
#include<queue>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<cmath>
#include<algorithm>
#include<random>
#include<ctime>

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,popcnt")

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;

mt19937 mt(time(0));
const int N = 5e5 + 2, mod = 998244353, inf = 1e9 + 100;
const ll llinf = 1e18 + 1000;
int n, q, a[N], pos[N];
void build() {
	vector<bool> used(n);
	int last = -1;
	for (int it = 0; it < n; ++it) {
		int mn = inf, mn1 = inf;
		for (int i = 0; i < n; ++i) {
			if (!used[i]) {
				mn1 = min(mn1, i);
				if (a[i] != last) mn = min(mn, i);
			}
		}
		if (mn == inf) mn = mn1;
		pos[mn] = it;
		last = a[mn];
		used[mn] = 1;
	}
}

void solve() {
	cin >> n >> q;
	for (int i = 0; i < n; ++i) cin >> a[i], --a[i];
	build();
	while (q--) {
		int ty, x;
		cin >> ty >> x;
		if (ty == 1) {
			--x;
			swap(a[x], a[x + 1]);
			build();
		}
		else {
			cout << pos[x - 1] + 1 << '\n';
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
		cout.flush();
	}
	return 0;
}