//#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];
ll pr[N][2];
void solve() {
  ll n, q;
  cin >> n >> q;
  for (ll i = 0; i < n; ++i) cin >> arr[i];

  pr[0][0] = (arr[0] == 1);
  pr[0][1] = (arr[0] == 2);
  for (ll i = 1; i < n; ++i) {
    pr[i][0] = pr[i - 1][0] + (arr[i] == 1);
    pr[i][1] = pr[i - 1][1] + (arr[i] == 2);
  }

  while (q--) {
    ll tq;
    cin >> tq;
    if (tq == 1) {
      ll tt;
      cin >> tt;
      swap(arr[tt - 1], arr[tt]);
    }
    else {
      ll y;
      cin >> y;
      --y;

      if (y == 0) {
        cout << "1\n";
        continue;
      }

      ll a = pr[n - 1][0], b = pr[n - 1][1];//arr[y]//not arr[y]
      if (arr[y] == 2) swap(a, b);

      ll cur = pr[y][arr[y] - 1];
      if (b >= cur) {
        if (arr[0] == arr[y]) cout << cur + cur - 1 << '\n';
        else cout << cur * 2 << '\n';
      }
      else cout << b + cur << '\n';
    }
  }
}

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

  return 0;
}