// Forza Ferrari!
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int &value : a) {
    cin >> value;
  }
  vector<bool> used(n);
  while (q --> 0) {
    int t;
    cin >> t;
    if (t == 1) {
      int x;
      cin >> x;
      --x;
      swap(a[x], a[x + 1]);
    } else {
      int guy;
      cin >> guy;
      --guy;
      int x = 0, y = 0, turn = 0, ans = 0;
      fill(used.begin(), used.end(), false);
      bool found = false;
      for (int i = 0; i < n; i++) {
        ++ans;
        if (turn) {
          while ((i > 0 && a[x] == a[y]) || used[x]) {
            ++x;
          }
          used[x] = true;
          if (x == guy) {
            found = true;
            break;
          }
        } else {
          while ((i > 0 && a[x] == a[y]) || used[y]) {
            ++y;
          }
          used[y] = true;
          if (y == guy) {
            found = true;
            break;
          }
        }
        if (max(x, y) == n) {
          break;
        }
        turn ^= 1;
      }
      if (!found) {
        --ans;
        for (int i = 0; i < n; i++) {
          if (!used[i]) {
            ++ans;
            if (i == guy) {
              break;
            }
          }
        }
      }
      cout << ans << "\n";
    }
  }
}
