#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int N = 2e5 + 7;
struct query {
  int l, r, t, id;
} q[N];
struct mdf {
  int pos, pre, now;
} d[N];
int n, m, B, l = 1, r, cnt, qcnt, mcnt, a[N], b[N], c[N], tmp[N], tot[N],
             num[N], ans[N];
bool cmp(query a, query b) {
  if ((a.l - 1) / B != (b.l - 1) / B) return a.l < b.l;
  return (a.r - 1) / B == (b.r - 1) / B ? a.t < b.t : a.r < b.r;
}
void add(int x, int v) { tot[num[x]]--, num[x] += v, tot[num[x]]++; }
void modify(int i, int f) {
  if (d[i].pos >= l && d[i].pos <= r) add(a[d[i].pos], -1);
  a[d[i].pos] = f == 1 ? d[i].now : d[i].pre;
  if (d[i].pos >= l && d[i].pos <= r) add(a[d[i].pos], 1);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), tmp[++cnt] = a[i];
  for (int i = 1; i <= m; i++) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1)
      q[++qcnt] = (query){x, y, mcnt, qcnt};
    else
      d[++mcnt] = (mdf){x, 0, y}, tmp[++cnt] = y;
  }
  sort(tmp + 1, tmp + cnt + 1);
  cnt = unique(tmp + 1, tmp + cnt + 1) - tmp - 1;
  for (int i = 1; i <= n; i++)
    a[i] = b[i] = lower_bound(tmp + 1, tmp + cnt + 1, a[i]) - tmp;
  for (int i = 1; i <= mcnt; i++) {
    d[i].now = lower_bound(tmp + 1, tmp + cnt + 1, d[i].now) - tmp;
    d[i].pre = b[d[i].pos], b[d[i].pos] = d[i].now;
  }
  B = pow(n, 0.67);
  sort(q + 1, q + qcnt + 1, cmp);
  for (int i = 1, tm = 0; i <= qcnt; i++) {
    while (tm < q[i].t) modify(++tm, 1);
    while (tm > q[i].t) modify(tm--, -1);
    while (r < q[i].r) add(a[++r], 1);
    while (l > q[i].l) add(a[--l], 1);
    while (r > q[i].r) add(a[r--], -1);
    while (l < q[i].l) add(a[l++], -1);
    ans[q[i].id] = 1;
    while (tot[ans[q[i].id]]) ans[q[i].id]++;
  }
  for (int i = 1; i <= qcnt; i++) printf("%d\n", ans[i]);
}
