#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#pragma GCC optimize("O3")
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < q; i++)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			int x;
			cin >> x;
			swap(a[x - 1], a[x]);
		}
		if (t == 2)
		{
			int y;
			cin >> y;
			vector<int> c(n);
			vector<bool> used(n, false);
			int r = 0;
			int cnt = 0;
			int p = -1;

			for (int j = 0; j < n; j++)
			{
				if (used[j])
					continue;
				if (a[j] != p)
				{
					c[j] = cnt++;
					used[j] = true;
					p = a[j];
					continue;
				}
				r = j;
				while (p == a[r] && r <= n-1)
				{
					r++;
					if (used[r])
						r++;
				}
				if (r >= n - 1 && p == a[r])
				{
					j--;
					for (; j < n-1; j++)
						c[j+1] = cnt++;
					break;
				}
				//cout << j << " " << r << "\n";
				c[r] = cnt++;
				used[r] = true;
				p = a[r];
				c[j] = cnt++;
				used[j] = true;
				p = a[j];
			}
			cout << c[y - 1] + 1 << "\n";
			/*for (auto el : c)
				cout << el << " ";
			cout << "\n";*/
		}
	}
	return 0;
}