#include <bits/stdc++.h>
using namespace std;
const int SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
const int B = 3000;
struct Query {
  int l, r, t, idx, bl, br;
  Query(int l, int r, int t, int idx)
      : l(l), r(r), t(t), idx(idx), bl(l / B), br(r / B) {}
  bool operator<(const Query &q) const {
    return tuple<int, int, int>(bl, br, t) <
           tuple<int, int, int>(q.bl, q.br, q.t);
  }
};
const int MAX = 100005;
int cnt[MAX], v[MAX], ocur[2 * MAX];
vector<pair<int, int> > updateForward, updateBackward;
void add(int pos) {
  int x = v[pos];
  cnt[ocur[x]]--;
  cnt[++ocur[x]]++;
}
void remove(int pos) {
  int x = v[pos];
  cnt[ocur[x]]--;
  cnt[--ocur[x]]++;
}
void applyUpdate(pair<int, int> upd, int l, int r) {
  auto [pos, val] = upd;
  if (l <= pos && pos <= r) remove(pos);
  v[pos] = val;
  if (l <= pos && pos <= r) add(pos);
}
int getAns() {
  int res = 0;
  while (cnt[res]) res++;
  return res;
}
vector<int> MO(vector<Query> queries) {
  cnt[0] = 0x3f3f3f3f;
  int l = 0, r = -1, t = 0;
  vector<int> ans(queries.size());
  sort(queries.begin(), queries.end());
  for (auto q : queries) {
    while (t < q.t) applyUpdate(updateForward[t++], l, r);
    while (q.t < t) applyUpdate(updateBackward[--t], l, r);
    while (q.l < l) add(--l);
    while (r < q.r) add(++r);
    while (l < q.l) remove(l++);
    while (q.r < r) remove(r--);
    ans[q.idx] = getAns();
  }
  return ans;
}
void create_queries(vector<pair<int, int> > updates) {
  int n = updates.size();
  for (int i = 0; i < n; i++) {
    auto [pos, val] = updates[i];
    updateForward.emplace_back(pos, val);
    updateBackward.emplace_back(pos, v[pos]);
    v[pos] = val;
  }
  for (int i = n - 1; i >= 0; i--) {
    auto [pos, val] = updateBackward[i];
    v[pos] = val;
  }
}
map<int, int> mp;
int compress(int x) {
  if (!mp.count(x)) mp[x] = mp.size();
  return mp[x];
}
void test_case() {
  int n, q, type, l, r, x;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v[i] = compress(x);
  }
  vector<pair<int, int> > updates;
  vector<Query> queries;
  for (int i = 0; i < q; i++) {
    cin >> type >> l >> r;
    if (type == 1)
      queries.emplace_back(l - 1, r - 1, updates.size(), queries.size());
    if (type == 2) updates.emplace_back(l - 1, compress(r));
  }
  create_queries(updates);
  vector<int> res = MO(queries);
  for (auto x : res) cout << x << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    test_case();
  }
  return 0;
}
