I won't feel lonely, nor will I be sorrowful... not before everything is buried.

A string of n beads is left as the message of leaving. The beads are numbered from 1 to n from left to right, each having a shape numbered by integers between 1 and n inclusive. Some beads may have the same shapes.

The memory of a shape x in a certain subsegment of beads, is defined to be the difference between the last position and the first position that shape x appears in the segment. The memory of a subsegment is the sum of memories over all shapes that occur in it.

From time to time, shapes of beads change as well as the memories. Sometimes, the past secreted in subsegments are being recalled, and you are to find the memory for each of them.

Input

The first line of input contains two space-separated integers n and m (1 ≤ n, m ≤ 100 000) — the number of beads in the string, and the total number of changes and queries, respectively.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ n) — the initial shapes of beads 1, 2, ..., n, respectively.

The following m lines each describes either a change in the beads or a query of subsegment. A line has one of the following formats: 

  * 1 p x (1 ≤ p ≤ n, 1 ≤ x ≤ n), meaning that the shape of the p-th bead is changed into x; 
  * 2 l r (1 ≤ l ≤ r ≤ n), denoting a query of memory of the subsegment from l to r, inclusive. 

Output

For each query, print one line with an integer — the memory of the recalled subsegment.

Examples

Input

7 6
1 2 3 1 3 2 1
2 3 7
2 1 3
1 7 2
1 3 2
2 1 6
2 5 7


Output

5
0
7
1


Input

7 5
1 3 2 1 4 2 3
1 1 4
2 2 3
1 1 7
2 4 5
1 1 7


Output

0
0

Note

The initial string of beads has shapes (1, 2, 3, 1, 3, 2, 1).

Consider the changes and queries in their order: 

  1. 2 3 7: the memory of the subsegment [3, 7] is (7 - 4) + (6 - 6) + (5 - 3) = 5; 
  2. 2 1 3: the memory of the subsegment [1, 3] is (1 - 1) + (2 - 2) + (3 - 3) = 0; 
  3. 1 7 2: the shape of the 7-th bead changes into 2. Beads now have shapes (1, 2, 3, 1, 3, 2, 2) respectively; 
  4. 1 3 2: the shape of the 3-rd bead changes into 2. Beads now have shapes (1, 2, 2, 1, 3, 2, 2) respectively; 
  5. 2 1 6: the memory of the subsegment [1, 6] is (4 - 1) + (6 - 2) + (5 - 5) = 7; 
  6. 2 5 7: the memory of the subsegment [5, 7] is (7 - 6) + (5 - 5) = 1. 
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 50;
inline int rd(register int x = 0, register char ch = getchar(),
              register int f = 0) {
  for (; ch < '0' || ch > '9'; ch = getchar()) f = ch == '-';
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + ch - 48;
  return f ? -x : x;
}
int n, m, cnt;
int a[N], pre[N], A[N], fr[N];
long long val[N], bit[N];
set<int> Set[N];
struct node {
  int t, x, y, val, op;
} q[N * 4], p[N * 4];
bool cmp(node a, node b) { return a.t < b.t; }
void add(int p, int v) {
  p += 5;
  for (; p <= n + 5; p += p & -p) bit[p] += v;
}
long long ask(int p, long long a = 0) {
  p += 5;
  if (p <= 0) return 0;
  for (; p; p -= p & -p) a += bit[p];
  return a;
}
void cdq(int l, int r) {
  if (l >= r) return;
  int mid = (l + r) >> 1, pl = l, pr = mid + 1, pp = l;
  cdq(l, mid), cdq(mid + 1, r);
  while (pl <= mid && pr <= r) {
    if (q[pl].x <= q[pr].x)
      p[pp] = q[pl++], fr[pp++] = 1;
    else
      p[pp++] = q[pr++];
  }
  while (pl <= mid) p[pp] = q[pl++], fr[pp++] = 1;
  while (pr <= r) p[pp++] = q[pr++];
  for (int pos = l; pos <= r; ++pos) {
    if (fr[pos] && !p[pos].op)
      add(p[pos].y, p[pos].val);
    else if (!fr[pos] && p[pos].op)
      val[p[pos].op] += ask(n) - ask(p[pos].y - 1);
  }
  for (int pos = l; pos <= r; ++pos) {
    q[pos] = p[pos];
    if (fr[pos] && !p[pos].op) add(p[pos].y, -p[pos].val);
    fr[pos] = 0;
  }
}
int main() {
  n = rd(), m = rd();
  for (int i = 1; i <= n; ++i) {
    a[i] = rd();
    if (Set[a[i]].size()) pre[i] = *--Set[a[i]].end();
    Set[a[i]].insert(i);
    q[++cnt] = (node){0, i, pre[i], i - pre[i], 0};
  }
  for (int r = 1; r <= m; ++r) {
    A[r] = rd();
    int b = rd(), c = rd();
    if (A[r] == 1) {
      q[++cnt] = (node){r, b, pre[b], pre[b] - b, 0};
      if (next(Set[a[b]].find(b)) != Set[a[b]].end()) {
        int pos = *next(Set[a[b]].find(b));
        q[++cnt] = (node){r, pos, pre[pos], pre[pos] - pos, 0};
        pre[pos] = pre[b];
        q[++cnt] = (node){r, pos, pre[pos], pos - pre[pos], 0};
      }
      Set[a[b]].erase(b);
      a[b] = c;
      pre[b] = 0;
      Set[a[b]].insert(b);
      if (Set[a[b]].find(b) != Set[a[b]].begin())
        pre[b] = *prev(Set[a[b]].find(b));
      q[++cnt] = (node){r, b, pre[b], b - pre[b], 0};
      if (next(Set[a[b]].find(b)) != Set[a[b]].end()) {
        int pos = *next(Set[a[b]].find(b));
        q[++cnt] = (node){r, pos, pre[pos], pre[pos] - pos, 0};
        pre[pos] = b;
        q[++cnt] = (node){r, pos, pre[pos], pos - pre[pos], 0};
      }
    } else
      q[++cnt] = (node){r, c, b, 0, r};
  }
  cdq(1, cnt);
  for (int i = 1; i <= m; ++i)
    if (A[i] == 2) printf("%lld\n", val[i]);
}
