#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

int a[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;

    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    while (q--) {
        int t, x;
        cin >> t >> x;

        if (t == 1) {
            swap(a[x], a[x + 1]);
        } else {
            if (x == 1) {
                cout << 1 << "\n";
            } else {
                int ans = 1;
                vector<bool> used(n + 1, 0);
                for (int i = 1; i <= n; ) {
                    used[i] = 1;
                    if (i == x) {
                        break;
                    }

                    int nxt = i;
                    for (int j = i + 1; j <= n; ++j) {
                        if (!used[j]) {
                            nxt = j;
                            break;
                        }
                    }

                    if (a[i] == a[nxt]) {
                        int k = -1;
                        for (int j = nxt + 1; j <= n; ++j) {
                            if (!used[j] && a[j] != a[nxt]) {
                                k = j;
                                break;
                            }
                        }

                        if (k == -1) {
                            i = nxt;
                            ++ans;
                        } else {
                            ++ans;
                            used[k] = 1;
                            if (k == x) {
                                break;
                            } else {
                                i = nxt;
                                ++ans;
                            }
                        }
                    } else {
                        i = nxt;
                        ++ans;
                    }
                }

                cout << ans << "\n";
            }
        }
    }

    return 0;
}