#pragma GCC optimize("O3", "unroll-loops")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC target("avx2")

using namespace std;
//using namespace __gnu_pbds;

using ll = long long;
template <int N, class T = ll>
using pii = array<T, N>;
//using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;

#ifdef LOCAL
ifstream iss32("in.txt");
#define cin iss32
#endif

constexpr ll N = 5e5 + 15;

ll arr[N];
void solve() {
  ll n, q;
  cin >> n >> q;
  for (ll i = 0; i < n; ++i) cin >> arr[i];


  while (q--) {
    ll tq;
    cin >> tq;
    if (tq == 1) {
      ll tt;
      cin >> tt;
      swap(arr[tt - 1], arr[tt]);
    }
    else {
      ll y;
      cin >> y;
      --y;

      set<pii<2>> st;
      vector<vector<ll>> tr(n + 1);
      for (ll i = 0; i < n; ++i) tr[arr[i]].push_back(i);
      for (ll i = 1; i <= n; ++i) {
        if (tr[i].size()) st.insert({ tr[i][0], i });
        reverse(tr[i].begin(), tr[i].end());
      }

      ll ot = 0;
      ll lst = 0;
      while (true) {
        ++ot;
        pii<2> t;
        if (st.size() == 1 || (*st.begin())[1] != lst) t = *st.begin();
        else t = *++st.begin();

        st.erase(t);
        if (t[0] == y) break;
        tr[t[1]].pop_back();
        if (tr[t[1]].size()) t[0] = tr[t[1]].back(), st.insert(t);
        lst = t[1];
      }

      cout << ot << '\n';
    }
  }
}

int main() {
  ll t = 1;
  //cin >> t;
  while (t--) solve();

  return 0;
}