#include <bits/stdc++.h>

using namespace std;

void solve();

// #include<ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r",stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    //cin>>t;
    while (t--) {
        solve();
    }
    return 0;
}

#define int long long
#define endl '\n'
const int N = 1e3, MOD = 998244353, INF = 2e18;
const double EPS = 1e-6, pi = acos(-1);

void solve() {
    int n,q;
    cin>>n>>q;
    vector<int> a(n);
    for (int i=0;i<n;i++) {
        cin>>a[i];
    }
    while (q--) {
        int t;
        cin>>t;
        if (t==1) {
            int x;
            cin>>x;
            x--;
            swap(a[x],a[x+1]);
        }else {
            int y;
            cin>>y;
            y--;
            vector<bool> del(n,false);
            int prev=-1,next=0;
            int cnt=0;
            for (int i=0;i<n;i++) {
                if (del[i])continue;
                del[i]=true;
                if (prev==a[i]) {
                    while (next<n && (a[next]==a[i] || del[next])) {
                        next++;
                    }
                    if (next!=n){
                        del[next]=true;
                        cnt++;
                        if (next==y) {
                            cout<<cnt<<endl;
                            break;
                        }
                    }
                    cnt++;
                    if (i==y) {
                        cout<<cnt<<endl;
                        break;
                    }
                }else {
                    cnt++;
                    if (i==y) {
                        cout<<cnt<<endl;
                        break;
                    }
                    prev=a[i];
                }
            }

        }
    }
}
