#include <bits/stdc++.h>
using namespace std;
const int len = 2154;
const int MAXN = 100010;
int n, q, a[MAXN], tmp[MAXN << 1], cntt = 0;
int pos[MAXN];
struct ques {
  int l, r, ind, tms;
  bool operator<(const ques& o) const {
    return pos[l] ^ pos[o.l]   ? pos[l] < pos[o.l]
           : pos[r] ^ pos[o.r] ? r < o.r
                               : tms < o.tms;
  }
} b[MAXN];
struct chgs {
  int p, x;
} c[MAXN];
int cntb = 0, cntc = 0;
int cnt[MAXN << 1], tot[MAXN << 1], l, r, ans[MAXN], now;
inline void add(int x) {
  --tot[cnt[x]];
  ++tot[++cnt[x]];
}
inline void del(int x) {
  --tot[cnt[x]];
  ++tot[--cnt[x]];
}
inline void modify(int k) {
  if (c[k].p >= l && c[k].p <= r) {
    del(a[c[k].p]);
    add(c[k].x);
  }
  swap(a[c[k].p], c[k].x);
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", a + i), tmp[++cntt] = a[i];
  for (int i = 1; i <= q; i++) {
    int opt;
    scanf("%d", &opt);
    if (opt & 1) {
      ++cntb;
      scanf("%d%d", &b[cntb].l, &b[cntb].r);
      b[cntb].ind = cntb;
      b[cntb].tms = cntc;
    } else {
      ++cntc;
      scanf("%d%d", &c[cntc].p, &c[cntc].x);
      tmp[++cntt] = c[cntc].x;
    }
  }
  sort(tmp + 1, tmp + cntt + 1);
  cntt = unique(tmp + 1, tmp + cntt + 1) - tmp - 1;
  for (int i = 1; i <= n; i++)
    a[i] = lower_bound(tmp + 1, tmp + cntt + 1, a[i]) - tmp;
  for (int i = 1; i <= cntc; i++)
    c[i].x = lower_bound(tmp + 1, tmp + cntt + 1, c[i].x) - tmp;
  for (int i = 1; i <= n; i++) pos[i] = (i - 1) / len + 1;
  sort(b + 1, b + cntb + 1);
  l = 1;
  r = 0;
  now = 0;
  for (int i = 1; i <= cntb; i++) {
    while (l > b[i].l) add(a[--l]);
    while (r < b[i].r) add(a[++r]);
    while (l < b[i].l) del(a[l++]);
    while (r > b[i].r) del(a[r--]);
    while (now < b[i].tms) modify(++now);
    while (now > b[i].tms) modify(now--);
    for (int& j = ans[b[i].ind] = 1; tot[j]; j++)
      ;
  }
  for (int i = 1; i <= cntb; i++) printf("%d\n", ans[i]);
  return 0;
}
