#include <bits/stdc++.h>

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;

const int mod = 1e9 + 7;

struct mint
{
    int x;

    mint(int x = 0) : x(x) {}

    friend mint operator+(mint a, mint b)
    {
        int res = a.x + b.x;
        return res - (res >= mod ? mod : 0);
    }

    friend mint operator-(mint a, mint b)
    {
        int res = a.x - b.x;
        return res + (res < 0 ? mod : 0);
    }

    friend mint operator*(mint a, mint b)
    {
        return ll(a.x) * b.x % mod;
    }
};

mint mpow(mint a, ll b)
{
    mint res = 1;
    while (b)
    {
        if (b & 1)
        {
            res = res * a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}

void rebuild(vector<int> &a, vector<int> &lnk)
{
    int n = a.size();
    int ptr1 = 0;
    int ptr2 = 0;
    fill(all(lnk), -1);
    while (true)
    {
        while (ptr2 < n && (a[ptr2] == a[ptr1] || lnk[ptr2] != -1))
        {
            ++ptr2;
        }
        if (ptr2 != n)
        {
            lnk[ptr1] = ptr2;
            swap(ptr1, ptr2);
        }
        else
        {
            break;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        if (lnk[i] == -1)
        {
            lnk[ptr1] = i;
            ptr1 = i;
        }
    }
}

void solve()
{
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    vector<int> lnk(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    rebuild(a, lnk);
    for (int i = 0; i < q; ++i)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int x;
            cin >> x;
            swap(a[x], a[x - 1]);
            rebuild(a, lnk);
        }
        else
        {
            int x;
            cin >> x;
            --x;
            int cur = 0, i = 0;
            for (; i < n && cur != x; ++i)
            {
                cur = lnk[cur];
            }
            cout << i + 1 << '\n';
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    solve();
}