#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx,avx2,bmi2,fma")
// mt19937 rnd(24523);

void dfs(int v, vector<int>& st, vector<int>& ans) {
    if (st[v] == 0) {
        return;
    }
    ans[st[v]] = ans[v] + 1;
    dfs(st[v], st, ans);
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, q;
    cin >> n >> q;
    vector<int> arr(n + 1), used(n + 1), st(n + 1), ans(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i];
    }
    for (int i = 1; i < n; ++i) {
        int j = 2, check = 0;
        for (; j <= n; ++j) {
            if (!used[j] && arr[i] != arr[j]) {
                used[j]++;
                check = true;
                break;
            }
        }
        if (check) {
            st[i] = j;
        } else {
            st[i] = i + 1;
        }
    }
    ans[1] = 1;
    dfs(1, st, ans);

    while (q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            if (arr[x] == arr[x + 1]) {
                continue;
            }
            swap(arr[x], arr[x + 1]);
            used.assign(n + 1, 0);
            st.assign(n + 1, 0);
            ans.assign(n + 1, 0);
            for (int i = 1; i < n; ++i) {
                int j = 2, check = 0;
                for (; j <= n; ++j) {
                    if (!used[j] && arr[i] != arr[j]) {
                        used[j]++;
                        check = true;
                        break;
                    }
                }
                if (check) {
                    st[i] = j;
                } else {
                    st[i] = i + 1;
                }
            }
            ans[1] = 1;
            dfs(1, st, ans);
        } else if (t == 2) {
            cout << ans[x] << endl;
        }
    }
    
}

/*
10 10
3 1 1 2 2 1 1 2 2 2
2 2
2 3
2 4
2 10
1 1
2 2
2 3
2 4
2 5
2 10

2
4
3
10
2
3
4
6
10


10 10
1 2 2 2 3 4 5 6 7 8
2 1
1 1
2 2
1 2
2 3
1 3
2 4
1 4
2 3
2 5

1
2
2
2
5
4


*/