#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define len(v) (int)v.size()

using namespace std;
using ll = long long;
using ld = long double;

void solve()
{
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 0; i < q; ++i)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int j;
            cin >> j;
            --j;
            swap(a[j], a[j + 1]);
        } else
        {
            int j;
            cin >> j;
            --j;
            vector<int> pl(n);
            pl[0] = 0;
            int lt = a[0];
            set<int> frst;
            vector<vector<int>> ids(n + 1);
            vector<int> num(n + 1, 0);
            for (int i = 1; i < n; ++i)
            {
                ids[a[i]].push_back(i);
                if (len(ids[a[i]]) == 1)
                {
                    frst.insert(i);
                }
            }
            for (int i = 1; i < n; ++i)
            {
                bool c = 0;
                for (int j : frst)
                {
                    if (a[j] != lt)
                    {
                        lt = a[j];
                        pl[j] = i;
                        c = 1;
                        frst.erase(j);
                        ++num[a[j]];
                        if (num[a[j]] < len(ids[a[j]]))
                        {
                            frst.insert(ids[a[j]][num[a[j]]]);
                        }
                        break;
                    }
                }
                if (!c)
                {
                    for (int j : frst)
                    {
                        lt = a[j];
                        pl[j] = i;
                        frst.erase(j);
                        ++num[a[j]];
                        if (num[a[j]] < len(ids[a[j]]))
                        {
                            frst.insert(ids[a[j]][num[a[j]]]);
                        }
                        break;
                    }
                }
            }
            cout << pl[j] + 1 << '\n';
        }
    }
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    //cin >> t;

    while (t--)
    {
        solve();
        cout << '\n';
    }
    return 0;
}

