//#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 t;
    cin >> t;
    if (t == 1) {
      cin >> t;
      swap(arr[t - 1], arr[t]);
    }
    else {
      ll y;
      cin >> y;
      --y;

      vector<pii<3>> st;
      {
        pii<3> t = { 0, 0, arr[0] };
        for (ll i = 1; i < n; ++i) {
          if (arr[i] != arr[i - 1]) {
            st.push_back(t);
            t = { i, i, arr[i] };
          }
          else t[1] = i;
        }
        st.push_back(t);
      }
      reverse(st.begin(), st.end());

      ll ot = 0;
      ll lst = 0;
      while (true) {
        ++ot;
        pii<3> t;
        if (st.size() == 1 || st.back()[2] != lst) t = st.back();
        else t = st[st.size() - 2], swap(st[st.size() - 1], st[st.size() - 2]);
        st.pop_back();

        if (t[0] == y) break;
        ++t[0];
        if (t[0] <= t[1]) {
          st.push_back(t);
          if (st.size() > 1 && st.back()[0] < st[ll(st.size()) - 2][0])
            swap(st[st.size() - 1], st[st.size() - 2]);
        }
        lst = t[2];
      }
      cout << ot << '\n';
    }
  }
}

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

  return 0;
}