// #define _GLIBCXX_DEBUG
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
// #define int long long
using ld = long double;
using ll = long long;
using pii = pair<int, int>;

int n, q;
vector<int> a, order;
set<pii> se;
vector<vector<int>> els;
vector<Seg> segs;

struct Seg {
  deque<int> d;
  int col;
};

void build_order() {
  els.clear();
  els.resize(n);
  segs.clear();
  segs.reserve(n);
  stack<int> st;
  Seg cur;
  bool has_seg = false;
  for (int i = n - 1; i >= 0; --i) {
    if (i != n - 1 && a[i] != a[i + 1]) {
      st.push(segs.size());
      segs.push_back(cur);
      has_seg = false;
    }
    if (!has_seg) {
      cur.col = a[i];
      cur.d.clear();
      has_seg = true;
    }
    cur.d.push_front(i);
  }
  st.push(segs.size());
  segs.push_back(cur);
  order.clear();
  while (st.size() > 1) {
    auto i1 = st.top();
    st.pop();
    auto i2 = st.top();
    st.pop();
    auto& a = segs[i1];
    auto& b = segs[i2];
    while (!a.d.empty() && !b.d.empty()) {
      if (a.d.size() == 1 && b.d.size() > 1) {
        order.push_back(a.d.front());
        a.d.pop_front();
      } else {
        order.push_back(a.d.front());
        order.push_back(b.d.front());
        a.d.pop_front();
        b.d.pop_front();
      }
    }
    if (!a.d.empty()) {
      if (!st.empty()) {
        int j = st.top();
        auto& c = segs[j];
        if (c.col == a.col) {
          st.pop();
          for (const auto& el : c.d) {
            a.d.push_back(el);
          }
        }
      }
      st.push(i1);
    }
    if (!b.d.empty()) {
      st.push(i2);
    }
  }
  if (!st.empty()) {
    assert(st.size() == 1);
    auto i = st.top();
    auto& a = segs[i];
    for (const auto& el : a.d) {
      order.push_back(el);
    }
    st.pop();
  }
  assert(order.size() == n);
}

void solve() {
  cin >> n >> q;
  a.resize(n);
  order.reserve(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }
  for (int qq = 0; qq < q; ++qq) {
    int t;
    cin >> t;
    if (t == 1) {
      int x;
      cin >> x;
      --x;
      swap(a[x], a[x + 1]);
    } else {
      int y;
      cin >> y;
      --y;
      build_order();
      for (int i = 0; i < n; ++i) {
        if (order[i] == y) {
          cout << i + 1 << '\n';
          break;
        }
      }
    }
  }
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

#ifdef ROMALOCAL
  freopen("in.txt", "r", stdin);
#endif

  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}