#include <bits/stdc++.h>
using namespace std;
int B, a[1000007], anw[1000007], ans, opt, pl, pr, Now_ti, n, m;
int ot, cnt, l, r;
int usd[1000007], ch;
int b[1000007];
template <class T>
inline void read(T &x) {
  static char c;
  static int b;
  for (b = 1, c = getchar(); !('0' <= c && c <= '9'); c = getchar())
    if (c == '-') b = -1;
  for (x = 0; ('0' <= c && c <= '9'); c = getchar()) x = x * 10 + c - 48;
  x *= b;
}
struct Node {
  int l, r, id, tim;
  inline bool operator<(const Node &A) const {
    if (((l - 1) / B + 1) ^ ((A.l - 1) / B + 1)) return l < A.l;
    if (((r - 1) / B + 1) ^ ((A.r - 1) / B + 1)) return r < A.r;
    return id < A.id;
  }
} g[1000007];
struct cha {
  int p, col, fre;
} p[1000007];
int pp, c[1000007], gg, usdd[1000007];
void add(int x) {
  pp = usdd[a[x]]++;
  if (pp < 1000007) usd[pp]--;
  if (pp + 1 < 1000007) usd[pp + 1]++;
}
void del(int x) {
  pp = usdd[a[x]]--;
  if (pp < 1000007) usd[pp]--;
  if (pp - 1 < 1000007) usd[pp - 1]++;
}
void change_add(int Tim) {
  opt = p[Tim].p;
  if (opt <= pr && pl <= opt) {
    del(opt);
    a[opt] = p[Tim].col;
    add(opt);
  }
  a[opt] = p[Tim].col;
}
void change_del(int Tim) {
  opt = p[Tim].p;
  if (opt <= pr && pl <= opt) {
    del(opt);
    a[opt] = p[Tim].fre;
    add(opt);
  }
  a[opt] = p[Tim].fre;
}
void change(int Tim) {
  while (Now_ti < Tim) change_add(++Now_ti);
  while (Now_ti > Tim) change_del(Now_ti--);
}
int dos() {
  for (int i = 1;; i++)
    if (!usd[i]) return i;
}
int main() {
  scanf("%d%d", &n, &m);
  B = (int)pow(n, 0.667);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i], c[i] = a[i];
  gg = n;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &ch);
    if (ch & 1) {
      ++ot;
      scanf("%d%d", &g[ot].l, &g[ot].r);
      g[ot].id = ot;
      g[ot].tim = cnt;
    } else {
      cnt++;
      scanf("%d%d", &p[cnt].p, &p[cnt].col);
      c[++gg] = p[cnt].col;
      p[cnt].fre = b[p[cnt].p];
      b[p[cnt].p] = p[cnt].col;
    }
  }
  sort(c + 1, c + gg + 1);
  for (int i = 1; i <= n; i++) a[i] = lower_bound(c + 1, c + gg, a[i]) - c;
  for (int i = 1; i <= cnt; i++)
    p[i].fre = lower_bound(c + 1, c + gg, p[i].fre) - c,
    p[i].col = lower_bound(c + 1, c + gg, p[i].col) - c;
  sort(g + 1, g + ot + 1);
  for (int i = 1; i <= ot; i++) {
    while (pl > g[i].l) add(--pl);
    while (pr < g[i].r) add(++pr);
    while (pl < g[i].l) del(pl++);
    while (pr > g[i].r) del(pr--);
    change(g[i].tim);
    anw[g[i].id] = dos();
  }
  for (int i = 1; i <= ot; i++) printf("%d\n", anw[i]);
  return 0;
}
