
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <unordered_map>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
ll mod = 998244353;
ll pow(ll n, ll k) {
    ll ans = 1;
    while (k) {
        if (k & 1) ans = ans * n % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return ans;
}
struct LiChao {
    struct Line {
        ll a = -1e18, b = 0;
        ll operator()(ll x) {
            return a + b * x;
        }
    };
    struct Node {
        Line li;
        ll l = 0, r = 0;
    };
    ll n;
    vector<Node> tree{Node(), Node()};
    LiChao(ll n) : n(n) {
    }
    void update(Line line, ll l, ll r, ll v) {
        if (l == r) {
            tree[v] = {line};
            return;
        };
        ll m = (l + r) >> 1;
        if (tree[v].li(m) < line(m)) {
            swap(line, tree[v].li);
        }
        if (tree[v].r == 0) {
            tree[v].r = tree.size();
            tree.push_back(Node());
            update(line, m + 1, r, tree[v].r);
            return;
        }
        if (tree[v].l == 0) {
            tree[v].l = tree.size();
            tree.push_back(Node());
            update(line, l, m, tree[v].l);
            return;
        }
        if (tree[tree[v].l].li(l) < line(l)) {
            update(line, l, m, tree[v].l);
        } else if (tree[tree[v].r].li(r) < line(r)) {
            update(line, m + 1, r, tree[v].r);
        }
    }
    ll get(ll x, ll l, ll r, ll v) {
        if (v == 0) return -1e18;
        if (l == r) {
            return tree[v].li(x);
        }
        ll m = (l + r) >> 1;
        if (x <= m) return max(tree[v].li(x), get(x, l, m, tree[v].l));
        else return max(tree[v].li(x), get(x, m + 1, r, tree[v].r));
    }
    void update(Line l) {
        update(l, -n, n, 1);
    }
    ll get(ll x) {
        return get(x, -n, n, 1);
    }
};

void solve() {
    ll n, q;
    cin >> n >> q;
    vll a(n);
    for (ll& i : a) cin >> i;
    for (ll _ = 0; _ < q; ++_) {
        ll t, i;
        cin >> t >> i;
        --i;
        if (t == 1) swap(a[i], a[i + 1]);
        else {
            vll vis(n, 0);
            ll cur = 0;
            for (ll j = 0; j <= n + 1; ++j) {
                if (i == cur) {
                    cout << j + 1 << '\n';
                    break;
                } 
                vis[cur] = 1;
                ll flag = 0;
                ll f = 1e18;
                for (ll i = 0; i < n; ++i) {
                    if (vis[i]) continue;
                    f = min(f, i);
                    if (a[i] != a[cur]) {
                        cur = i;
                        flag = 1;
                        break;
                    }
                }
                if (!flag) cur = f;
            }
        }
    }
}

int main() {
    //freopen("in.txt", "r", stdin);
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t = 1;
    for (int i = 0; i < t; ++i) {
        solve();
    }
    cout << endl;
    return 0;
}
