#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
using ll = long long;

template<typename T>
using ordered_set = tree<T, null_type, less<T>,
    rb_tree_tag, tree_order_statistics_node_update>;

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

template<typename T, typename Y>
ostream &operator<<(ostream &out, const pair<T, Y> &a) {
    return out << a.first << ' ' << a.second;
}

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 (const auto &i : a) {
        out << i << ' ';
    }
    return out;
}

template<typename T>
void print(const vector<T> &a, string c = "\n") {
    for (const auto &i : a) {
        cout << i << c;
    }
}

void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    cin >> a;
    for (int i = 0; i < q; ++i) {
        int t, y;
        cin >> t >> y;
        --y;
        if (t == 1) {
            swap(a[y], a[y + 1]);
            continue;
        }
        if (y == 0) {
            cout << "1\n";
            continue;
        }
        vector<int> ans(n);
        int lst = a[0], cnt = 1, did = 0, lst_val = 1;
        for (int j = 1; j < n; ++j) {
            if (a[j] == lst) {
                ++cnt;
                ans[j] = lst_val + 2;
                lst_val = ans[j];
                continue;
            }
            did += 2;
            --cnt;
            ans[j] = did;
            if (cnt == 0) {
                lst_val = did;
                --did;
                lst = a[j];
                cnt = 1;
            }
        }
        int c = 0;
        for (int k = n - 1; k >= 0; --k) {
            if (a[k] == lst) {
                ++c;
                if (c == cnt) {
                    break;
                }
                ans[k] = n - c + 1;
            }
        }
        cout << ans[y] << '\n';
    }
}

int main() {
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int times = 1;
    // cin >> times;
    while (times--) {
        solve();
        cout << '\n';
    }
}
