#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long
#define vc vector
#define db double
#define str string
#define its(a) (a).begin(), (a).end()
#define itsr(a) (a).rbegin(), (a).rend()
#define sz(a) (a).size()
#define tstr to_string
#define scan(a) for (auto &_i:a) cin >> _i;



void solve() {
	/*vc<ll> tr;
	auto get = [&](auto get, int v, int l, int r, int lq, int rq) -> ll {
		if (lq <= l and r <= rq) return tr[v];
		if (rq <= l or r <= lq) return 0;
		int mid = (r + l) >> 1;
		return get(get, 2 * v + 1, l, mid, lq, rq) + get(get, 2 * v + 2, mid, r, lq, rq);
	};
	auto build = [&](auto build, int v, int l, int r) -> void {
		if (r - l == 1) {
			tr[v] = a[l];
			return;
		}
		int mid = (r + l) >> 1;
		build(build, 2 * v + 1, l, mid);
		build(build, 2 * v + 2, mid, r);
		tr[v] = tr[2 * v + 1] + tr[2 * v + 2];
	};
	auto st = [&](auto st, int v, int l, int r, int e, int x) -> void {
		if (r - l == 1) {
			tr[v] = x;
			return;
		}
		int mid = (r + l) >> 1;
		if (e < mid) st(st, 2 * v + 1, l, mid, e, x);
		else st(st, 2 * v + 2, mid, r, e, x);
		tr[v] = tr[2 * v + 1] + tr[2 * v + 2];
	};*/

	ll n, q; cin >> n >> q;
	vc<ll> a(n); scan(a);

	vc<ll> pr(n, -1);
	vc<ll> sol(n);
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if (a[i] != a[j] and pr[j] == -1) {
				pr[i] = j;
				pr[j] = i;
			}
		}
		if (pr[i] == -1) sol[i] = 1;
		else sol[i] = 2;
	}

	vc<ll> used(n);
	for (int i = 0; i < n; ++i) {
		ll t; cin >> t;
		if (t == 1) {
			ll x; cin >> x;
			--x;
			swap(a[x], a[x + 1]);
		}
		else {
			ll ask; cin >> ask;
			--ask;
			ll p = 1;
			ll cur = 0;
			used.assign(n, 0);
			ll pr = -1;
			ll mxs = n-1;
			for (; mxs >= 0; --mxs) if (a[mxs] != a[n - 1]) break;

			if (a[mxs] != a[n - 1])++mxs;
			if (a[mxs] != a[n - 1])++mxs;

			for (int j = 0; j < n; ++j) {
				if (used[j] or (pr == a[j] and !(mxs <= j))) continue;
				used[j] = 1;
				while (p < n and (used[p] or a[p] == a[j])) {
					++p;
				}
				if (p < n) {
					used[j] = used[p] = 1;
					if (j == ask) {
						cout << cur+1 << '\n';
						break;
					}
					if (p == ask) {
						cout << cur+2 << '\n';
						break;
					}
					pr = a[p];
					cur += 2;
				}
				else {
					if (ask == j) {
						cout << cur+1 << '\n';
						break;
					}
					++cur;
				}
			}
		}
	}

	
	

}

int main()
{
	cin.tie(0)->sync_with_stdio(0);

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