#include<bits/stdc++.h>
using namespace std;
int n, q;
int a[500005];
void read()
{
    cin >> n >> q;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
}
void type1(int x)
{
    swap(a[x], a[x+1]);
}
int num[500005];
void type2(int y)
{
    priority_queue <int> free;
    for(int i = 2; i <= n; i++)
    {
        free.push(-i);
    }
    int last = 1;
    num[1] = 1;
    vector <int> v;
    while(last != y)
    {
        int c;
        bool lamp = 0;
        v.clear();
        while(!free.empty())
        {
            ///cout << last << " ";
            c = -free.top();
            free.pop();
            if(a[c] != a[last])
            {
                num[c] = num[last] + 1;
                last = c;
                lamp = 1;
                break;
            }
            else
            {
                v.push_back(-c);
            }
        }
        for(int i = 0; i < v.size(); i++)
            free.push(v[i]);
        if(lamp == 0)
        {
            c = -free.top();
            num[c] = num[last]+1;
            last = c;
            free.pop();
        }
    }
    ///cout << endl;
    cout << num[y] << endl;
}
void solve()
{
    int t, x;
    for(int i = 1; i <= q; i++)
    {
        cin >> t >> x;
        if(t == 1)type1(x);
        else type2(x);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    read();
    solve();
    return 0;
}

