#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int a[N], e[N], f[N];
int k, c[N], d[N], b[N];
map<int, int> ma;
struct que {
  int l, r, posl, posr, ts, id;
} q[N];
struct modi {
  int pos, x, pre;
} mo[N];
bool cmp(que a, que b) {
  if (a.posl == b.posl) {
    if (a.posr == b.posr) return a.ts < b.ts;
    return a.posr < b.posr;
  }
  return a.posl < b.posl;
}
void update(int x, int p) {
  if (x == 0) return;
  if (c[x] > 0) d[c[x]]--;
  c[x] += p;
  if (c[x] > 0) d[c[x]]++;
}
void modify(int x, int p, int l, int r) {
  if (x >= l && x <= r) {
    update(a[x], -1);
    update(p, 1);
  }
  a[x] = p;
}
int fun() {
  for (int i = 1;; i++)
    if (d[i] < 1) return i;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int p = pow(n, 0.666666);
  if (p == 0) p = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), e[i] = f[i] = a[i];
  sort(f + 1, f + 1 + n);
  k = unique(f + 1, f + 1 + n) - (f + 1);
  for (int i = 1; i <= k; i++) ma[f[i]] = i;
  for (int i = 1; i <= n; i++) e[i] = a[i] = ma[a[i]];
  int tot = 0, cnt = 0, len = k;
  int op, x, y;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      q[tot].l = x, q[tot].posl = x / p;
      q[tot].r = y, q[tot].posr = y / p;
      q[tot].id = tot, q[tot++].ts = cnt;
    } else {
      if (!ma[y]) ma[y] = ++len;
      y = ma[y];
      mo[++cnt].pos = x, mo[cnt].pre = e[x];
      mo[cnt].x = y, e[x] = y;
    }
  }
  sort(q, q + tot, cmp);
  int l = 0, r = 0, cn = 0;
  for (int i = 0; i < tot; i++) {
    while (cn < q[i].ts) modify(mo[cn + 1].pos, mo[cn + 1].x, l, r), cn++;
    while (cn > q[i].ts) modify(mo[cn].pos, mo[cn].pre, l, r), cn--;
    while (l < q[i].l) update(a[l++], -1);
    while (l > q[i].l) update(a[--l], 1);
    while (r > q[i].r) update(a[r--], -1);
    while (r < q[i].r) update(a[++r], 1);
    b[q[i].id] = fun();
  }
  for (int i = 0; i < tot; i++) printf("%d\n", b[i]);
  return 0;
}
