#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5e5+5;

int n,q;
int a[MAXN];


int used[MAXN];
void ask(int x)
{
    used[1] = 1;
    int timer = 1;
    int lastc = a[1];

    int pu = 2;
    for(int i = 2; i <= n; i++)
    {
        while(used[pu]) pu++;

        if(pu < i && a[pu] != lastc)
        {
            used[pu] = (++timer);
            lastc = a[pu];
        }
        if(a[i] != lastc)
        {
            used[i] = (++timer);
            lastc = a[i];
        }
    }
    for(int i = 1; i <= n; i++) if(!used[i]) used[i] = (++timer);
}

void read()
{
    cin >> n >> q;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    ask(1);

    int t,x;
    for(int i = 1; i <= q; i++)
    {
        cin >> t >> x;
        if(t == 1)
        {
            swap(a[x],a[x+1]);
            if(a[x] != a[x+1])
            {
                if(used[x] > used[x+1]) swap(used[x],used[x+1]);
            }
        }
        else
        {
            cout << used[x] << endl;
        }
    }
}
int main()
{
    read();
    return 0;
}
