#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

const int MOD = 1e9 + 7;
const int Inf = 2e9;
const ll INF = 3e18;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector <int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int x;
      cin >> x;
      x--;
      swap(a[x], a[x+1]);
    } else {
      int y;
      cin >> y;
      y--;
      vector <int> num(n, -1);
      vector <deque <int>> idx(n);
      for (int i = 0; i < n; i++) {
        idx[a[i]].push_back(i);
      }
      set <int> mn;
      for (int i = 0; i < n; i++) {
        if (!idx[i].empty()) {
          mn.insert(idx[i].front());
        }
      }
      int prev = -1;
      for (int i = 0; i < n; i++) {
        auto it = mn.begin();
        if (a[*it] == prev) {
          it++;
        }
        if (it != mn.end()) {
          int pos = *it;
          mn.erase(it);
          prev = a[pos];
          num[pos] = i;
          idx[a[pos]].pop_front();
          if (!idx[a[pos]].empty()) {
            mn.insert(idx[a[pos]].front());
          }
        } else {
          it--;
          int pos = *it;
          mn.erase(it);
          num[pos] = i;
          idx[a[pos]].pop_front();
          if (!idx[a[pos]].empty()) {
            mn.insert(idx[a[pos]].front());
          }
        }
      }
      cout << num[y] + 1 << '\n';
    }
  }
  return 0;
}