#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];

    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;

            vi vis(n);

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

            vis[0] = 1;

            int prev = a[0];
            
            int gok = 0;
            for (int i = 1; i < n; ++i) {
                int ok = 0;
                if (gok) break;
                if (ok) continue;
                for (int j = 0; j < n; ++j) {
                    if (ok || gok) break;
                    if (vis[j]) continue;
                    if (a[j] == prev) continue;
                    if (j == y) {
                        cout << i + 1 << '\n';
                        gok = 1;
                        ok = 1;
                        prev = a[j];
                        break;
                    } else {
                        prev = a[j];
                        vis[j] = 1;
                        ok = 1;
                        continue;
                    }
                }

                if (!ok) {
                    for (int j = 0; j < n; ++j) {
                        if (ok || gok) break;
                        if (vis[j]) continue;
                        if (j == y) {
                            cout << i + 1 << '\n';
                            gok = 1;
                            ok = 1;
                            prev = a[j];
                            break;
                        } else {
                            prev = a[j];
                            vis[j] = 1;
                            ok = 1;
                            break;
                        }
                    }                
                }
            }
        }
    }
}