#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int r = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) r = (r << 1) + (r << 3) + (c ^ 48), c = getchar();
  return r;
}
inline int min(int a, int b) { return a < b ? a : b; }
inline void swap(int &a, int &b) {
  int c = a;
  a = b;
  b = c;
}
int n, m, t, l, r, size, a[101101], lb[101101], rb[101101], pos[101101],
    cnt_cnt[101101], tot[101101], ans[101101];
int s_lsh, lsh[101101 << 1], cnt[101101 << 1];
int b[101101][2];
struct Q {
  int l, r, t, num;
  bool operator<(const Q &q) const {
    return pos[l] ^ pos[q.l] ? pos[l] < pos[q.l]
           : pos[r] ^ pos[q.r]
               ? pos[l] & 1 ? pos[r] < pos[q.r] : pos[r] > pos[q.r]
           : pos[r] & 1 ? t < q.t
                        : t > q.t;
  }
} q[101101];
inline void change(int x, int val) {
  tot[pos[cnt[a[x]]]] -= (cnt_cnt[cnt[a[x]]] == 1);
  cnt_cnt[cnt[a[x]]]--;
  cnt[a[x]] += val;
  cnt_cnt[cnt[a[x]]]++;
  tot[pos[cnt[a[x]]]] += (cnt_cnt[cnt[a[x]]] == 1);
}
inline void modify(int x) {
  if (b[x][0] >= l && b[x][0] <= r) {
    change(b[x][0], -1);
    swap(a[b[x][0]], b[x][1]);
    change(b[x][0], 1);
  } else
    swap(a[b[x][0]], b[x][1]);
}
inline int query() {
  for (int i = 1; i <= pos[n]; i++) {
    if (tot[i] == rb[i] - lb[i] + 1) continue;
    for (int j = lb[i]; j <= rb[i]; j++)
      if (!cnt_cnt[j]) return j;
  }
  return n + 1;
}
inline int find(int x) {
  int l = 0, r = s_lsh + 1;
  while (l + 1 < r) {
    int mid = (l + r) >> 1;
    if (lsh[mid] <= x)
      l = mid;
    else
      r = mid;
  }
  return l;
}
int main() {
  n = read(), m = read();
  s_lsh = n;
  size = pow(n, 0.67);
  for (int i = 1; i <= n; i++) {
    pos[i] = (i - 1) / size + 1;
    a[i] = lsh[i] = read();
  }
  for (int i = 1; i <= pos[n]; i++) {
    lb[i] = (i - 1) * size + 1;
    rb[i] = min(lb[i] + size - 1, n);
  }
  for (int i = 1; i <= m; i++) {
    int opt = read();
    if (opt & 1) {
      q[i - t].l = read(), q[i - t].r = read(), q[i - t].t = t;
      q[i - t].num = i - t;
    } else
      b[++t][0] = read(), lsh[++s_lsh] = b[t][1] = read();
  }
  sort(lsh + 1, lsh + 1 + s_lsh);
  for (int i = 2; i <= s_lsh; i++)
    if (lsh[i] == lsh[i - 1]) lsh[i - 1] = 1e9 + 10;
  sort(lsh + 1, lsh + 1 + s_lsh);
  for (int i = 1; i <= n; i++) a[i] = find(a[i]);
  for (int i = 1; i <= t; i++) b[i][1] = find(b[i][1]);
  m -= t;
  sort(q + 1, q + m + 1);
  cnt[0] = n;
  l = q[1].l, r = q[1].l - 1, t = 0;
  for (int i = 1; i <= m; i++) {
    while (l > q[i].l) change(--l, 1);
    while (r < q[i].r) change(++r, 1);
    while (l < q[i].l) change(l++, -1);
    while (r > q[i].r) change(r--, -1);
    while (t < q[i].t) modify(++t);
    while (t > q[i].t) modify(t--);
    ans[q[i].num] = query();
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
