#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using ll = long long;
#define int long long
template<typename T>
using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;

template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &a) {
    return in >> a.first >> a.second;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &a) {
    return out << a.first << ' ' << a.second << '\n';
}

template<typename T>
istream &operator>>(istream &in, vector<T> &a) {
    for (auto &i: a)in >> i;
    return in;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &a) {
    for (auto &i: a)out << i << ' ';
    return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<vector<T> > &a) {
    for (auto &i: a)out << i << '\n';
    return out;
}

constexpr int mod = 998244353;

template<typename T>
T fast_pow(T a, int n) {
    if (n == 0)return 1;
    if (n % 2 == 1)return a * fast_pow(a, n - 1);
    T t = fast_pow(a, n / 2);
    return t * t;
}

struct Zm {
    int k;

    Zm(int k = {}) : k(k % mod) {
        if (this->k < 0)this->k += mod;
    }

    Zm operator+(const Zm &other) const {
        return {k + other.k};
    }

    Zm operator-(const Zm &other) const {
        return {k - other.k};
    }

    Zm operator*(const Zm &other) const {
        return {k * other.k};
    }
};

struct Test {
    int n;
    vector<int> a;
    vector<int> p;

    Test() {
        cin >> n;
        int q;
        cin >> q;
        a.resize(n);
        cin >> a;
        p.resize(n, -1);
        p[0] = 0;
        {
            int res=a[0];
            int now = 1;
            int stop = 1;
            int cnt=1;
            while (now < n) {
                while (stop < now && p[stop] != -1)stop++;
                if (stop!=now && a[stop] != res) {
                    p[stop] = cnt++;
                    res=a[stop];
                } else if (a[now] != res) {
                    p[now] = cnt++;
                    res=a[now];
                    now++;
                } else now++;
            }
            while (stop < n) {
                if (p[stop] == -1) {
                    p[stop] = cnt++;
                }
                stop++;
            }
            //cout<<a<<'\n'<<p<<'\n'<<res<<'\n'<<'\n';
        }
        bool flag=false;
        while (q--) {
            int t;
            cin >> t;
            int ind;
            cin >> ind;
            ind--;
            if (t == 1) {
                swap(a[ind],a[ind+1]);
                flag=true;

            } else {
                if (flag) {
                    int res=a[0];
                    int now = 1;
                    int stop = 1;
                    fill(p.begin(), p.end(),-1);
                    p[0]=0;
                    int cnt=1;
                    while (now < n) {
                        while (stop < now && p[stop] != -1)stop++;
                        if (stop!=now && a[stop] != res) {
                            p[stop] = cnt++;
                            res=a[stop];
                        } else if (a[now] != res) {
                            p[now] = cnt++;
                            res=a[now];
                            now++;
                        } else now++;
                    }
                    while (stop < n) {
                        if (p[stop] == -1) {
                            p[stop] = cnt++;
                        }
                        stop++;
                    }
                    //cout<<a<<'\n'<<p<<'\n'<<res<<'\n'<<'\n';
                    flag=true;
                }
                cout << p[ind] + 1 << '\n';
            }
        }
    }
};

signed main() {
#ifdef home
    freopen(".in", "r",stdin);
    freopen(".out", "w",stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        Test();
    }
}
