#include <bits/stdc++.h>

using namespace std;

#define f(i, n) for(int i=0;i<n;i++)
#define ll long long
#define MOD (ll)998244353
#define int ll
#define vi vector<int>
#define vvi vector<vi>

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, q;
    cin >> n >> q;
    vi a(n);
    vi was(n);
    f(i, n)
        cin >> a[i];
    f(req, q)
    {
        int t;
        cin >> t;
        int x;
        cin >> x;
        if (t == 1)
        {
            swap(a[x-1], a[x]);
        }
        else
        {
            was.assign(n, 0);
            x--;
            if (x == 0)
            {
                cout << 1 << '\n';
            }
            else
            {
                was[0] = 1;
                int lst = a[0];
                int cnt = 1;
                while (cnt < n)
                {
                    int nxt = -1;
                    f(i, n)
                    {
                        if (!was[i] && nxt == -1)
                            nxt = i;
                        if (!was[i] && a[i] != lst)
                        {
                            nxt = i;
                            break;
                        }
                    }
                    cnt++;
                    was[nxt] = 1;
                    lst = a[nxt];
                    if (nxt == x)
                    {
                        cout << cnt << '\n';
                        break;
                    }
                }
            }
        }
    }
    return 0;
}