#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 = max(j, r);
				bool f = false;
				while (p == a[r] && r < n-1)
				{
					r++;
					while (used[r] && r < n-1)
						r++;
					if (!used[r] && a[r] != p)
						f = true;
				}
				if (!f)
				{
					//cout << "b " << j << "\n";
					for (; j < n; j++)
					{
						if (!used[j])
						c[j] = 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";*/
		}
	}
	getchar();
	getchar();
	return 0;
}

