#include <iostream>
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using lll = __int128;
using pii = pair <int, int>;
template <typename T>
using vec = vector <T>;

#define all(x) x.begin(), x.end()

template <typename T>
istream& operator >>(istream& in, vec <T>& a) {
    for (auto& x : a) in >> x;
    return in;
}
template <typename T>
ostream& operator <<(ostream& in, vec <T>& a) {
    for (T x : a) in << x << " ";
    return in;
}
template <typename T, typename Y>
istream& operator >>(istream& in, pair <T, Y>& a) {
    in >> a.first >> a.second;
    return in;
}
template <typename T, typename Y>
ostream& operator <<(ostream& in, pair <T, Y>& a) {
    in << a.first << " " << a.second;
    return in;
}
void FAST() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int INF = 1e9 + 7;
const ll LLINF = 1e18 + 7;
const ll MOD = 998'244'353;

int main() {
    FAST();

    int n, q;
    cin >> n >> q;
    vec <int> a(n);
    cin >> a;
    while (q--) {
        int t, ind;
        cin >> t >> ind;
        ind--;
        if (t == 1) swap(a[ind], a[ind + 1]);
        else {
            int cnt = 1, lastc = -1, start = 0;
            vec <bool> used(n);
            used[0] = 1;
            //cout << "ans: ";
            if (ind == 0) {
                cout << "1\n";
                continue;
            }
            //cout << a << endl;
            //cout << "st: 0 " << a[0] << endl;
             for (int j = 0; j < n; j++) {
                    //if (j == start) continue;
                    if (!used[j] && a[j] != a[start]) {
                        cnt++;
                        start = j;
                        //cout << "st: " << start << " " << a[start] << "\n";
                        used[j] = 1;
                        //cout << used << endl;
                        if (start == ind) {
                            cout << cnt << "\n";
                            //break;
                        }
                        j = 0;
                    }
             }

            if (start != ind) {
                for (int i = 0; i < n; i++) {
                    if (!used[i]) {
                        cnt++;
                        used[i] = 1;
                        if (i == ind) {
                            cout << cnt << "\n";
                            break;
                        }
                    }
                }
            }
            //cout << "\n";
        }
    }
}