#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<iomanip>
#include<queue>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<cmath>
#include<algorithm>
#include<random>
#include<ctime>

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,popcnt")

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;

mt19937 mt(time(0));
const int N = 5e5 + 2, K = 5, mod = 998244353, inf = 1e9 + 100;
const ll llinf = 1e18 + 1000;
int n, q, a[N];
struct segtree {
	struct node {
		int suf, sum;
		node() : suf(0), sum(0) {}
		node(int _x) : suf(max(0, _x)), sum(_x) {}
		node operator+(node a) {
			node ans;
			ans.suf = max(suf + a.sum, a.suf);
			ans.sum = sum + a.sum;
			return ans;
		}
	};
	int val = -1;
	node t[N * 2];
	void build(int v, int l, int r) {
		if (r - l == 1) {
			t[v] = node((a[l] == val) ? 1 : -1);
			return;
		}
		int m = (l + r) >> 1;
		build(v + 1, l, m);
		build(v + 2 * (m - l), m, r);
		t[v] = t[v + 1] + t[v + 2 * (m - l)];
	}
	void build(int x) {
		val = x;
		build(0, 0, n);
	}
	void upd(int v, int l, int r, int i) {
		if (r - l == 1) {
			t[v] = node((a[l] == val) ? 1 : -1);
			return;
		}
		int m = (l + r) >> 1;
		if (i < m) upd(v + 1, l, m, i);
		else
			upd(v + 2 * (m - l), m, r, i);
		t[v] = t[v + 1] + t[v + 2 * (m - l)];
	}
	void upd(int i) {
		upd(0, 0, n, i);
	}
	node get(int v, int l, int r, int ql, int qr) {
		if (r <= ql || qr <= l) return node();
		if (ql <= l && r <= qr) return t[v];
		int m = (l + r) >> 1;
		return get(v + 1, l, m, ql, qr) + get(v + 2 * (m - l), m, r, ql, qr);
	}
	node get(int r) {
		return get(0, 0, n, 0, r);
	}
};
segtree t;

void solve() {
	cin >> n >> q;
	for (int i = 0; i < n; ++i) cin >> a[i], --a[i];
	t.build(0);
	while (q--) {
		int ty, x;
		cin >> ty >> x;
		if (ty == 1) {
			--x;
			swap(a[x], a[x + 1]);
			t.upd(x);
			t.upd(x);
		}
		else {
			--x;
			int g = t.get(x + 1).suf;
			if (a[x] == 0) cout << min(n, x + g) << ' ';
			else
				cout << x - g << ' ';
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
		cout.flush();
	}
	return 0;
}