#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <queue>
using namespace std;
using ll = int;
using ld = long double;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvll = vector<vll>;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

void in(vll& a) {
	for (ll& i : a) cin >> i;
}

void out(vll& a) {
	for (ll& i : a) cout << i << ' ';
	cout << '\n';
}

void in(vpll& a) {
	for (pll& i : a) cin >> i.first >> i.second;
}

void in(vvll& a) {
	for (auto& v : a) {
		for (auto& x : v) cin >> x;
	}
}

vll get(vll& a) {
	ll n = a.size();
	vll main{ 0 }, idx(n);
	queue<ll> skip;
	for (ll i = 1; i < n; ++i) {
		if (a[main.back()] == a[i]) {
			skip.push(i);
			continue;
		}
		else idx[i] = main.size(), main.push_back(i);
		if (!skip.empty()) {
			idx[skip.front()] = main.size();
			main.push_back(skip.front());
			skip.pop();
		}
	}
	while (!skip.empty()) {
		idx[skip.front()] = main.size();
		main.push_back(skip.front()), skip.pop();
	}
	return idx;
}

void solve() {
	ll n, q; cin >> n >> q;
	vll a(n);
	in(a);
	auto idx = get(a);
	for (ll i = 0; i < q; ++i) {
		ll t; cin >> t;
		if (t == 1) {
			ll x; cin >> x; --x;
			swap(a[x], a[x + 1]);
			idx = get(a);
		}
		else {
			ll y; cin >> y; --y;
			cout << idx[y] + 1 << '\n';
		}
	}
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	ll ts = 1;
	//cin >> ts;
	while (ts--) solve();
}