#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int l = 1, r = 0;
int a[MAXN], b[MAXN], now[MAXN], num[MAXN << 1], cnt[MAXN], ans[MAXN];
map<int, int> ms;
struct Change {
  int p, x, y;
} c[MAXN];
struct Query {
  int l, r, t, id;
  bool operator<(const Query &A) const {
    if (b[l] == b[A.l]) return b[r] == b[A.r] ? t < A.t : b[r] < b[A.r];
    return b[l] < b[A.l];
  }
} q[MAXN];
void update(int x, int d) {
  int &y = num[x];
  if (y > 0) cnt[y]--;
  y += d;
  if (y > 0) cnt[y]++;
}
void modify(int p, int d) {
  if (l <= p && p <= r) {
    update(a[p], -1);
    update(d, 1);
  }
  a[p] = d;
}
int get() {
  for (int i = 1;; i++) {
    if (!cnt[i]) return i;
  }
}
int main() {
  int n, m, id = 0, Time = 0, sz = 0;
  scanf("%d%d", &n, &m);
  int B = 2000;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    int &t = ms[a[i]];
    if (!t) t = ++sz;
    now[i] = a[i] = t;
    b[i] = i / B + 1;
  }
  while (m--) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1)
      q[++id] = (Query){x, y, Time, id};
    else {
      int &t = ms[y];
      if (!t) t = ++sz;
      c[++Time] = (Change){x, y = t, now[x]};
      now[x] = y;
    }
  }
  sort(q + 1, q + id + 1);
  int v = 0;
  for (int i = 1; i <= id; i++) {
    while (v < q[i].t) modify(c[v + 1].p, c[v + 1].x), v++;
    while (v > q[i].t) modify(c[v].p, c[v].y), v--;
    while (l < q[i].l) update(a[l], -1), l++;
    while (l > q[i].l) update(a[l - 1], 1), l--;
    while (r < q[i].r) update(a[r + 1], 1), r++;
    while (r > q[i].r) update(a[r], -1), r--;
    ans[q[i].id] = get();
  }
  for (int i = 1; i <= id; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
