// Created by rost on 05.03.2026.

#include <bits/stdc++.h>

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

void solve() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;

  int col = 0;
  vector<int> used(n);
  for (int qi = 0; qi < q; ++qi) {
    int t;
    cin >> t;

    if (t == 1) {
      int x;
      cin >> x;
      swap(a[x - 1], a[x]);
    } else {
      int y;
      cin >> y;

      ++col;

      int k = 0, lastCol = -1;
      for (int i = 0; i < n; ++i) {
        if (used[i] == col) continue;

        if (a[i] == lastCol) {
          for (int j = i + 1; j < n; ++j) {
            if (a[j] != a[i]) {
              k++;

              if (y - 1 == j) cout << k << '\n';

              used[j] = col;
              break;
            }
          }
        }


        k++;
        if (y - 1 == i) cout << k << '\n';
        used[i] = col;
        lastCol = a[i];
      }
    }
  }
}

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

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