#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
const ll MAXN = 1e5 + 6;
const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;
mt19937 rnd(2);
ll ans[MAXN];
int main() {
    ll n,q,a,b;
    cin >> n >> q;
    vector<ll> arr;
    for (int i = 0;i<n;i++) {
        cin >> a;
        arr.push_back(a);
    }
    vector<ll> index(n,0);
    vector<ll> un_index(n,0);
    vector<bool> used(n,false);
    for (int tr = 0;tr<q;tr++) {
        cin >> a >> b;
        b--;
        if (a == 1) {
            swap(arr[b],arr[b+1]);
        }
        else {
            deque<pair<ll,ll>> st;
            ll color = -1;
            ll p = 0;
            for (int i = 0;i<n;i++) {
                if (color == arr[i]) {
                    st.push_back({arr[i],i});
                }
                else {
                    if (i == b) {
                        cout << p + 1 << "\n";
                        break;
                    }
                    color = arr[i];
                    p++;
                    if (st.size() > 0) {
                        if (st.front().second == b) {
                            cout << p + 1 << "\n";
                            st.pop_front();
                            break;
                        }
                        color = st.front().first;
                        st.pop_front();
                        p ++;
                    }
                }
            }
            for (int j = 0;j<st.size();j++) {
                if (st[j].second == b) {
                    cout << p + 1 << "\n";
                    break;
                }
                p ++;
            }
        }
    }
}
