#include<vector>
#include <algorithm>
#include <iostream>
#include <map>
#include <deque>

using namespace std;
#define int long long

const int inf = 1e18;

const int mxn = 2e5 + 7;
const int  lgx = 22;
int t[mxn];
int mod = 998244353;
int lg[mxn];
int st[lgx];

void print(vector<int>& a)
{
	for (auto x : a)
		cout << x << " ";
	cout << "\n";
}


int maxx(int l, int r,vector<vector<int>> &sp)
{
	int ln = r - l + 1;
	return max(sp[lg[ln]][l], sp[lg[ln]][r - st[lg[ln]] + 1]);
}

int sm(int r)
{
	int res = 0;
	for (;r > 0; r -= r & (-r))
		res += t[r];
	return res;
}

int sm(int l, int r)
{
	return sm(r) - sm(l - 1);
}

void add(int i, int x)
{
	for (; i < mxn; i += i & (-i))
		t[i] += x;
}

struct node 
{
	int add, sm;
};

struct Tree
{
	int len = 1;
	vector<node> tr;

	void init(int n)
	{
		while (len < n)
			len *= 2;
		tr.assign(2 * len - 1, { 0, -1 });
	}

	void push(int x, int ln)
	{
		if (tr[x].add != -1)
		{
			tr[2 * x + 1].sm = tr[x].add * ln / 2;
			tr[2 * x + 1].add = tr[x].add;

			tr[2 * x + 2].sm = tr[x].add * ln / 2;
			tr[2 * x + 2].add = tr[x].add ;

			tr[x].sm = tr[x].add * ln;
			tr[x].add = -1;
		}
	}

	void add(int x, int lx, int rx, int l, int r, int v)
	{
		
		if (l <= lx && rx <= r)
		{
			tr[x].add = v;
			tr[x].sm = v * (rx - lx + 1);
			return;
		}

		if (l > rx || r < lx)
		{
			return;
		}
		push(x, rx - lx + 1);
		int m = (lx + rx) / 2;
		add(2 * x + 1, lx, m, l, r, v);
		add(2 * x + 2, m + 1, rx, l, r, v);
		tr[x].sm = tr[2 * x + 1].sm + tr[2 * x + 2].sm;
	}

	int sm(int x, int lx, int rx, int l, int r)
	{
		if (l <= lx && rx <= r)
		{
			return tr[x].sm;
		}

		if (l > rx || r < lx)
		{
			return 0 ;
		}
		push(x, rx - lx + 1);
		int m = (lx + rx) / 2;
		int s1 = sm(2 * x + 1, lx, m, l, r);
		int s2 = sm(2 * x + 2, m + 1, rx, l, r);
		return s1 + s2;
	}

	void add(int l, int r, int v)
	{
		add(0, 0, len - 1, l, r, v);
	}

	int sm(int l, int r)
	{
		return sm(0, 0, len - 1, l, r);
	}
};



int pw(int a, int b)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
	{
		int q = pw(a, b / 2);
		return q * q % mod;
	}
	int q = pw(a, b - 1);
	return q * a % mod;
}

vector<int> ob(vector<int> p)
{
	vector<int> q(p.size(), 0);
	for (int i = 0; i < p.size(); i++)
		q[p[i] - 1] = i + 1;
	return q;
}

vector<int> pr(vector<int> p)
{
	vector<int> q(p.size(), 0);
	for (int i = 0; i < p.size(); i++)
		q[i] = q.size() - p[i] + 1;
	return q;
}


int sc(vector<int> a)
{
	int ans = 0;
	for (int i = 0; i < a.size(); i++)
		ans = (pw(a[i], i + 1) + ans) % mod;
	return  ans;
}


signed main()
{
	int n;
	int q;
	cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	while (q--)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			int x;
			cin >> x;
			x--;
			swap(a[x], a[x + 1]);
		}
		else
		{
			int y;
			cin >> y;
			y--;
			vector<int> b(1 , 1);
			vector<int> c(1, a[0]);
			int okx = 0;
			int j = 0;
			if (y == 0)
				okx = 1;
			for (int i = 1; i < n; i++)
			{
				if (a[i] == a[i - 1])
				{
					if (okx == 0)
						b[b.size() - 1] ++;
				}
				else
				{
					b.push_back(1);
					c.push_back(a[i]);
					okx = 0;
				}
				if (i == y)
				{
					okx = 1;
					j = b.size() - 1;
				}
			}
			int u = 0;
			int un = 1;
			int ch = 1;
			int ans = 0;
			int pr = -1;
			int fl = 0;
			if (j == 0)
				fl = 1;
			while (!((fl == 0 && b[j] == 0) || (fl == 1 && b[u] == 0)))
			{
				ans++;
				if (ch)
				{
					b[u]--;
					ch = 0;
					if (b[u] == 0)
					{
						ch = 1;
						u = un;
						un++;
						if (fl)
							break;
					}
					
				}
				else
				{
					if (un != b.size())
					{
						b[un]--;
						if (b[un] == 0)
						{
							un++;
							if (un != b.size() && c[un] == c[u])
							{
								if (fl == 0)
								{
									b[u] += b[un];
									if (un == j)
									{
										fl = 1;
									}
								}
								un++;
							}
						}

					}
					else
						b[u]--;
					ch = 1;
				}
			}

			cout << ans << "\n";
		}
	}
}
