#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

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

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    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 t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            x--;
            swap(a[x], a[x + 1]);
        } else {
            int x;
            cin >> x;
            x--;
            int cnt = 0;
            int k = 0;
            int pos = 0;
            int c = -1;
            int c2 = -1;
            int w = 0;
            while (w + k < n) {
                if (k != 0 && c != c2) {
                    w++;
                    if (cnt == 1) {
                        cnt = 0;
                        cout << w << "\n";
                        break;
                    }
                    if (cnt > 1) {
                        cnt--;
                    }
                    k--;
                    c = c2;
                    if (k == 0) {
                        c2 = -1;
                    }
                } else if (a[pos] == c) {
                    k++;
                    if (pos == x) {
                        cnt = k;
                    }
                    c2 = a[pos];
                    pos++;
                } else {
                    w++;
                    if (pos == x) {
                        cout << w << "\n";
                        break;
                    }
                    c = a[pos];
                    pos++;
                }
            }
            if (cnt > 0) {
                cout << cnt + w << "\n";
            }
        }
    }
}
