#include <iostream>
#include <string>
#include<vector>
#include<map>
using namespace std;
// TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
int main() {

    int n, q;
    cin >> n >> q;
    vector<int> a(n);

    for (int i = 0; i < n ; i++) {
        cin >> a[i];
    }
    int t, x;
    for (int i = 0; i < q; i ++) {
        cin >> t >> x;
        if (t == 1) {
            x = x -1;
            int b = a[x];
            a[x] = a[x+1];
            a[x+1] = b;

        }
        else {
            vector<int> visited;
            for (int i = 0; i < n; i ++) {
                visited.push_back(1);
            }
            int last= a[0];
            int last_ind = 0;
            int added = 1;
            int global = 1;
            visited[0] = 0;
            for (int i = 1; i < n; i ++) {
                //cout << last_ind;
                if (last_ind + 1 == x) {
                    cout<< added<< "\n";
                    break;
                }
                else {
                    if (global == 0) {
                        for (int i = 0; i < n ; i ++) {
                            if (visited[i] == 1) {
                                last = a[i];
                                last_ind = i;
                                visited[i] = 0;
                                added += 1;
                                break;
                            }
                        }
                    }
                    else {
                        int flag = 0;
                        for (int i = 0; i < n ; i ++) {
                            if (visited[i] == 1 and a[i] != last) {
                                last = a[i];
                                flag = 1;
                                last_ind = i;
                                visited[i] = 0;
                                added += 1;
                                break;
                            }
                        }
                        global = flag;
                        if (flag == 0) {
                            for (int i = 0; i < n ; i ++) {
                                if (visited[i] == 1) {
                                    last = a[i];
                                    last_ind = i;
                                    visited[i] = 0;
                                    added += 1;
                                    break;
                                }
                            }
                        }

                    }




                }
            }
            if (last_ind + 1 == n and n == x) {
                cout<< added<< "\n";
            }
        }
    }

    return 0;
    // TIP See CLion help at <a href="https://www.jetbrains.com/help/clion/">jetbrains.com/help/clion/</a>. Also, you can try interactive lessons for CLion by selecting 'Help | Learn IDE Features' from the main menu.
}