/*#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    vector<int> am1(n + 1, 0), am2(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 1)
            am1[i + 1] = am1[i] + 1;
        else
            am1[i + 1] = am1[i];
        if (a[i] == 2)
            am2[i + 1] = am2[i] + 1;
        else
            am2[i + 1] = am2[i];
    }

    for (int i = 0; i < q; ++i) {
        int type;
        cin >> type;
        if (type == 1) {
            int x;
            cin >> x;
            if (a[x - 1] == a[x])
                continue;
            if (a[x - 1] == 1) {
                --am1[x];
                ++am2[x];
            } else {
                --am2[x];
                ++am1[x];
            }
            swap(a[x - 1], a[x]);
        } else {
            int x;
            cin >> x;
            if (x == 1) {
                cout << 1 << endl;
                continue;
            }
            --x;
            int val = a[x];
            if (val == 1) {
                if (am1[1] != 0)
                    cout << am1[x + 1] + min(am2.back(), am1[x + 1] - 1) << endl;
                else
                    cout << 1 + am1[x + 1] + min(am2.back() - 1, am1[x + 1] - 1) << endl;
            } else {
                if (am2[1] != 0)
                    cout << am2[x + 1] + min(am1.back(), am2[x + 1] - 1) << endl;
                else
                    cout << 1 + am2[x + 1] + min(am1.back() - 1, am2[x + 1] - 1) << endl;
            }
        }
    }
}*/

#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.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 type, x;
        cin >> type >> x;
        if (type == 1) {
            swap(a[x - 1], a[x]);
        } else {
            int mx = 0;
            vector<int> t(n);
            vector<int> used(n, 0);
            used[0] = 1;
            t[0] = 1;
            int now = 0, now_t = 2;
            deque<int> unuse;
            for (int j = 1; j < n; ++j)
                unuse.push_back(j);
            for (int j = 1; j < n; ++j) {
                while (!unuse.empty() && used[unuse[0]])
                    unuse.pop_front();
                if (now > unuse[0]) {
                    now = unuse[0];
                } else {
                    int k = mx + 1;
                    for (; k < n; ++k)
                        if (a[k] != a[now]) {
                            now = k;
                            break;
                        }
                    if (k == n)
                        now = unuse[0];
                }
                t[now] = now_t;
                used[now] = 1;
                mx = max(mx, now);
                ++now_t;
            }
            cout << t[x - 1] << endl;
        }
    }
}
