#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <numeric>

#define LOCAL
#ifdef LOCAL
#else
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#endif

const long long modul = 998'244'353;

void Solve() {
    int n, q;
    std::cin >> n >> q;

    std::vector<int> vec(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> vec[i];
    }

    std::vector<int> res;
    std::vector<bool> used(n);
    int type, number;
    for (int i = 0; i < q; ++i) {
        std::cin >> type >> number;
        --number;

        if (type == 1) {
            std::swap(vec[number], vec[number + 1]);
        } else {
            res.clear();
            used.assign(n, false);
            used[0] = true;

            res.push_back(0);
            while (res.back() != number) {
                int need = 1e7;
                bool flag = true;
                for (int j = 0; j < n; ++j) {
                    if (!used[j] and vec[res.back()] != vec[j]) {
                        res.push_back(j);
                        used[j] = true;
                        flag = false;
                        break;
                    }

                    if (!used[j]) {
                        need = std::min(need, j);
                    }
                }

                if (flag) {
                    res.push_back(need);
                    used[need] = true;
                }
            }

            std::cout << res.size() << '\n';
        }
    }

}

int main() {
    #ifdef LOCAL
        std::cout << '\n';
    #else
        std::ios_base::sync_with_stdio(false);
        std::cin.tie(nullptr);
    #endif

    int t = 1;
    //std::cin >> t;

    for (int i = 0; i < t; ++i) {
        Solve();
    }
}