#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 20;
int cntt[N];
int cnt[N], a[N], b[N], c[N];
struct Q {
  int l, r, id, t;
} qu[N];
int m, n, t;
int pos[N], val[N], lval[N];
int len;
int ret[N];
bool cmp(Q a, Q b) {
  int b1 = (a.l - 1) / len + 1, b2 = (b.l - 1) / len + 1;
  int b3 = (a.r - 1) / len + 1, b4 = (b.r - 1) / len + 1;
  if (b1 == b2) {
    if (b3 == b4) return a.t < b.t;
    return b3 < b4;
  }
  return b1 < b2;
}
inline void add(int x) {
  cntt[cnt[x]]--;
  cnt[x]++;
  cntt[cnt[x]]++;
}
inline void remove(int x) {
  cntt[cnt[x]]--;
  cnt[x]--;
  cntt[cnt[x]]++;
}
inline void inst(int l, int r, int t) {
  a[pos[t]] = val[t];
  if (l <= pos[t] && pos[t] <= r) {
    add(val[t]);
    remove(lval[t]);
  }
}
inline void delt(int l, int r, int t) {
  a[pos[t]] = lval[t];
  if (l <= pos[t] && pos[t] <= r) {
    add(lval[t]);
    remove(val[t]);
  }
}
inline void del(int x) { remove(a[x]); }
inline void ins(int x) { add(a[x]); }
void solve() {
  for (int i = 1, l = 1, r = 0, t = 0; i <= m; i++) {
    Q &q = qu[i];
    while (q.t > t) t++, inst(l, r, t);
    while (q.r > r) r++, ins(r);
    while (q.l < l) l--, ins(l);
    while (q.l > l) del(l), l++;
    while (q.r < r) del(r), r--;
    while (q.t < t) delt(l, r, t), t--;
    for (ret[q.id] = 1; cntt[ret[q.id]]; ret[q.id]++)
      ;
  }
}
int main() {
  int q, tot = 0;
  ;
  scanf("%d%d", &n, &q);
  len = pow(n, 2.00 / 3);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i], c[++tot] = a[i];
  for (int i = 1; i <= q; i++) {
    int opt;
    scanf("%d", &opt);
    if (opt == 1) {
      ++m;
      scanf("%d%d", &qu[m].l, &qu[m].r);
      qu[m].t = t;
      qu[m].id = m;
    }
    if (opt == 2) {
      ++t;
      scanf("%d%d", &pos[t], &val[t]);
      c[++tot] = val[t];
      lval[t] = b[pos[t]];
      b[pos[t]] = val[t];
    }
  }
  sort(c + 1, c + tot + 1);
  tot = unique(c + 1, c + tot + 1) - c - 1;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(c + 1, c + tot + 1, a[i]) - c;
  for (int i = 1; i <= t; i++)
    val[i] = lower_bound(c + 1, c + tot + 1, val[i]) - c;
  for (int i = 1; i <= t; i++)
    lval[i] = lower_bound(c + 1, c + tot + 1, lval[i]) - c;
  sort(qu + 1, qu + m + 1, cmp);
  solve();
  for (int i = 1; i <= m; i++) printf("%d\n", ret[i]);
  return 0;
}
