// #pragma GCC target("avx2")
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
using ld = long double;

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, q;
    cin >> n >> q;

    vi a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    vi used;

    for (int id = 0; id < q; ++id) {
        int t;
        cin >> t;

        if (t == 1) {
            int x;
            cin >> x;
            --x;
            swap(a[x], a[x + 1]);
        } else {
            int y;
            cin >> y;
            --y;

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

            used.assign(n, 0);

            int m1 = 0;
            int m2 = 0;
            
            while ((m2 < n) && (a[m1] == a[m2])) ++m2;

            int prev = -1;


            for (int i = 0; i < n; ++i) {
                int sc = 0;
                if (a[m1] != prev) {
                    if (m1 == y) {
                        cout << i + 1 << '\n';
                        break;
                    }
                    used[m1] = 1;
                    prev = a[m1];
                    ++m1;
                } else if (m2 != n) {
                    sc = 1;
                    if (m2 == y) {
                        cout << i + 1 << '\n';
                        break;
                    }
                    used[m2] = 1;
                    prev = a[m2];
                    ++m2;
                } else {
                    if (m1 == y) {
                        cout << i + 1 << '\n';
                        break;
                    }

                    used[m1] = 1;
                    prev = a[m1];
                }

                while ((m1 < n) && used[m1]) ++m1;
                m2 = max(m2, m1 + 1);

                if (m1 == n) break;

                while ((m2 < n) && ((used[m2]) || (a[m1] == a[m2]))) ++m2;
            }
        }
    }
}