#include <bits/stdc++.h>
using namespace std;
int read() {
  int res = 0, f = 1;
  char ch = ' ';
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    res = res * 10 + ch - '0';
    ch = getchar();
  }
  return res * f;
}
const int N = 2e5 + 5;
int n, m;
int a[N], belong[N], ans[N];
int pre[N], pos[N], num, c[N], sum1, sum2, _size, kkk, times, tot[N];
void write(int x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
struct node1 {
  int l, r, id, pre;
} t[N];
struct node2 {
  int pos, color;
} p[N];
int cnt[N];
void del(int x) {
  tot[cnt[x]]--;
  tot[--cnt[x]]++;
}
void add(int x) {
  tot[cnt[x]]--;
  tot[++cnt[x]]++;
}
void work(int now, int i) {
  if (t[i].l <= p[now].pos && p[now].pos <= t[i].r) {
    del(a[p[now].pos]);
    add(p[now].color);
  }
  swap(p[now].color, a[p[now].pos]);
}
void solve() {
  int l = 1, r = 0, now = 0;
  for (register int i = 1; i <= sum1; i++) {
    int ql = t[i].l, qr = t[i].r;
    while (l < ql) del(a[l]), l++;
    while (l > ql) l--, add(a[l]);
    while (r < qr) r++, add(a[r]);
    while (r > qr) del(a[r]), r--;
    while (now < t[i].pre) work(++now, i);
    while (now > t[i].pre) work(now--, i);
    ans[t[i].id] = 1;
    while (tot[ans[t[i].id]]) {
      ans[t[i].id]++;
    }
  }
  for (register int i = 1; i <= sum1; i++) {
    write(ans[i]);
    puts("");
  }
}
bool cmp(node1 x, node1 y) {
  return belong[x.l] == belong[y.l]
             ? (belong[x.r] == belong[y.r] ? x.pre < y.pre : x.r < y.r)
             : x.l < y.l;
}
int main() {
  n = read();
  m = read();
  _size = pow(n, 0.66666666);
  kkk = ceil((double)n / _size);
  for (register int i = 1; i <= kkk; i++) {
    for (register int j = (i - 1) * _size + 1; j <= i * _size; j++) {
      belong[j] = i;
    }
  }
  for (register int i = 1; i <= n; i++) a[i] = read(), c[++num] = a[i];
  for (register int i = 1; i <= m; i++) {
    int opt = read(), x = read(), y = read();
    if (opt == 2) {
      c[++num] = y;
      sum2++;
      p[sum2].pos = x;
      p[sum2].color = y;
    }
    if (opt == 1) {
      sum1++;
      t[sum1].l = x;
      t[sum1].r = y;
      t[sum1].pre = sum2;
      t[sum1].id = sum1;
    }
  }
  sort(t + 1, t + 1 + sum1, cmp);
  sort(c + 1, c + 1 + num);
  times = unique(c + 1, c + 1 + num) - c - 1;
  for (register int i = 1; i <= n; i++) {
    a[i] = lower_bound(c + 1, c + 1 + num, a[i]) - c;
  }
  for (register int i = 1; i <= sum2; i++) {
    p[i].color = lower_bound(c + 1, c + 1 + num, p[i].color) - c;
  }
  solve();
  return 0;
}
