#include <bits/stdc++.h>
using namespace std;
inline int rd() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) {
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x;
}
int n, m, B, opt, x, y, t1, t2, tot, len, _;
int a[100005 << 1], id[100005], ct[100005 << 1], cnt[100005], ans[100005];
struct T {
  int i, x;
  bool operator<(const T &b) const { return x < b.x; }
} t[100005 << 1];
struct Q {
  int l, r, i, t;
  bool operator<(const Q &b) const {
    return id[l] ^ id[b.l] ? l < b.l : id[r] ^ id[b.r] ? r < b.r : t < b.t;
  }
} q[100005];
struct C {
  int i, x;
} c[100005];
inline void init() {
  sort(t + 1, t + 1 + len);
  for (int i = 1; i <= len; ++i) {
    if (t[i].x ^ t[i - 1].x) ++tot;
    if (t[i].i > n) {
      c[t[i].i - n].x = tot;
    } else {
      a[t[i].i] = tot;
    }
  }
}
inline void add(int x) { --cnt[ct[x]], ++cnt[++ct[x]]; }
inline void del(int x) { --cnt[ct[x]], ++cnt[--ct[x]]; }
inline void work(int t, int i) {
  if (q[i].l <= c[t].i && c[t].i <= q[i].r) {
    del(a[c[t].i]), add(c[t].x);
  }
  (_ = a[c[t].i], a[c[t].i] = c[t].x, c[t].x = _);
}
inline int query(int i = 1) {
  while (cnt[i]) ++i;
  return i;
}
inline void Mo() {
  int l = 1, r = 0, t = 0;
  sort(q + 1, q + 1 + t1);
  for (int i = 1; i <= t1; ++i) {
    const int &L = q[i].l, &R = q[i].r;
    while (l > L) add(a[--l]);
    while (r < R) add(a[++r]);
    while (l < L) del(a[l++]);
    while (r > R) del(a[r--]);
    while (t < q[i].t) work(++t, i);
    while (t > q[i].t) work(t--, i);
    ans[q[i].i] = query();
  }
}
int main() {
  n = rd(), m = rd();
  B = pow(n, 2.0 / 3);
  for (int i = 1; i <= n; ++i) {
    t[i] = (T){i, rd()};
    id[i] = i / B;
  }
  len = n;
  while (m--) {
    opt = rd(), x = rd(), y = rd();
    if (opt & 1) {
      ++t1, q[t1] = (Q){x, y, t1, t2};
    } else {
      c[++t2] = (C){x, y};
      t[++len] = (T){t2 + n, y};
    }
  }
  init(), Mo();
  for (int i = 1; i <= t1; ++i) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
