#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")

#define endl '\n'
#define X first
#define Y second
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector <unsigned long long> vull;
typedef vector <string> vs;
typedef pair <int, int> pii;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


const int maxn = 5e5 + 7;
int n, q;
int a[maxn];
int b[maxn];
int c[maxn];
void fill_b()
{
    queue <int> q;
    int t = 1;

    for(int i = 1;i <= n;i++)
    {
        if(t == 1)
        {
            b[i] = t;
            c[1] = a[1];
            t++;
            continue;
        }
        if(!q.empty() && a[q.front()] != c[t - 1])
        {
            c[t] = a[q.front()];
            b[q.front()] = t;
            t++;
            q.pop();
        }
        if(a[i] == c[t - 1])
        {
            q.push(i);
        }
        else if(a[i] != c[t - 1])
        {
            c[t] = a[i];
            b[i] = t;
            t++;
            continue;
        }
    }
    while(!q.empty())
    {
        c[t] = a[q.front()];
        b[q.front()] = t;
        t++;
        q.pop();
    }
}
void read_solve()
{
    cin >> n >> q;
    for(int i = 1; i <= n;i++)
    {
        cin >> a[i];
    }
    fill_b();
    for(int i = 1; i <= q;i++)
    {
        int t;
        cin >> t;
        if(t == 1)
        {
            int x;
            cin >> x;
            swap(a[x], a[x + 1]);
            fill_b();
        }
        else
        {
            int y;
            cin >> y;
            cout << b[y] << endl;
        }
    }
}

int main()
{
    speed();
    read_solve();
    return 0;
}
