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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll MOD = 998244353;
const int N = 5e5 + 5;
int a[N];

int main() {
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	
	int n, q;
	cin >> n >> q;

	for (int i = 1; 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], a[x + 1]);
		}
		else {
			int y;
			cin >> y;

			if (y == 1) {
				cout << 1 << '\n';
				continue;
			}

			int ans = 1;

			int ind = 2;
			int prev = a[1];
			bool done = false;
			list<int> tmp;
			while (ind <= n) {
				if (!tmp.empty() && a[tmp.front()] != prev) {
					ans++;
					if (y == tmp.front()) {
						done = true;
						break;
					}
					prev = a[tmp.front()];
					tmp.pop_front();
				}

				if (a[ind] == prev) {
					tmp.push_back(ind);
					ind++;
					continue;
				}

				ans++;
				prev = a[ind];
				if (ind == y) {
					done = true;
					break;
				}
				ind++;
			}

			if (!done) {
				for (auto i : tmp) {
					if (i <= y) {
						ans++;
					}
				}
			}

			cout << ans << '\n';
		}
	}


	return 0;
}