Problem: Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weather to scuba-diving in oceans and admiring the sea life, residing unseen. These experiences were enhanced with breathtaking views built by mountains over time and left there for visitors to see for years on end. Over time, all these expeditions took a toll on Sarah and culminated in her decision to settle down in the suburbs and live a quiet life. 

However, as Sarah's love for nature never faded, she started growing flowers in her garden in an attempt to stay connected with nature. At the beginning she planted only blue orchids, but over time she started using different flower types to add variety to her collection of flowers. This collection of flowers can be represented as an array of N flowers and the i-th of them has a type associated with it, denoted as A_i. Each resident, passing by her collection and limited by the width of his view, can only see K contiguous flowers at each moment in time. To see the whole collection, the resident will look at the first K contiguous flowers A_1, A_2, ..., A_K, then shift his view by one flower and look at the next section of K contiguous flowers A_2, A_3, ..., A_{K+1} and so on until they scan the whole collection, ending with section A_{N-K+1}, ..., A_{N-1}, A_N.

Each resident determines the beautiness of a section of K flowers as the number of distinct flower types in that section. Furthermore, the beautiness of the whole collection is calculated by summing the beautiness values of each contiguous section. Formally, beautiness B_i of a section starting at the i-th position is calculated as B_i = distinct(A_i, A_{i+1}, ..., A_{i+K-1}), and beautiness of the collection B is calculated as B=B_1 + B_2 + ... + B_{N-K+1}.

In addition, as Sarah wants to keep her collection of flowers have a fresh feel, she can also pick two points L and R, dispose flowers between those two points and plant new flowers, all of them being the same type.

You will be given Q queries and each of those queries will be of the following two types: 

  1. You will be given three integers L, R, X describing that Sarah has planted flowers of type X between positions L and R inclusive. Formally collection is changed such that A[i]=X for all i in range [L.. R]. 
  2. You will be given integer K, width of the resident's view and you have to determine the beautiness value B resident has associated with the collection 



For each query of second type print the result – beautiness B of the collection.

Input

First line contains two integers N and Q \;(1 ≤ N, Q ≤ 10^5)  — number of flowers and the number of queries, respectively.

The second line contains N integers A_1, A_2, ..., A_N\;(1 ≤ A_i ≤ 10^9)  — where A_i represents type of the i-th flower.

Each of the next Q lines describe queries and start with integer T∈\{1, 2\}. 

  * If T = 1, there will be three more integers in the line L, R, X\;(1 ≤ L, R ≤ N;\; 1 ≤ X ≤ 10^9)  — L and R describing boundaries and X describing the flower type 
  * If T = 2, there will be one more integer in the line K\;(1 ≤ K ≤ N)  — resident's width of view 

Output

For each query of the second type print the beautiness B of the collection.

Example

Input


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


Output


9
6
4

Note

Let's look at the example.

Initially the collection is [1, 2, 3, 4, 5]. In the first query K = 3, we consider sections of three flowers with the first being [1, 2, 3]. Since beautiness of the section is the number of distinct flower types in that section, B_1 = 3. Second section is [2, 3, 4] and B_2 = 3. Third section is [3, 4, 5] and B_3 = 3, since the flower types are all distinct. The beautiness value resident has associated with the collection is B = B_1 + B_2 + B_3 = 3 + 3 + 3 = 9.

After the second query, the collection becomes [5, 5, 3, 4, 5]. 

For the third query K = 4, so we consider sections of four flowers with the first being [5, 5, 3, 4]. There are three distinct flower types [5, 3, 4] in this section, so B_1 = 3. Second section [5, 3, 4, 5] also has 3 distinct flower types, so B_2 = 3. The beautiness value resident has associated with the collection is B = B_1 + B_2 = 3 + 3 = 6

After the fourth query, the collection becomes [5, 5, 5, 5, 5].

For the fifth query K = 2 and in this case all the four sections are same with each of them being [5, 5]. Beautiness of [5, 5] is 1 since there is only one distinct element in this section [5]. Beautiness of the whole collection is B = B_1 + B_2 + B_3 + B_4 = 1 + 1 + 1 + 1 = 4

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int n, cq, a[N + 9];
void into() {
  scanf("%d%d", &n, &cq);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
}
struct answer {
  struct tree {
    long long sum, add;
  } tr[N * 4 + 9];
  void Pushup(int k) { tr[k].sum = tr[k << 1].sum + tr[k << 1 | 1].sum; }
  void Update_add(int k, int l, int r, long long v) {
    tr[k].sum += v * (r - l + 1);
    tr[k].add += v;
  }
  void Pushdown(int k, int l, int r) {
    if (!tr[k].add) return;
    int mid = l + r >> 1;
    Update_add(k << 1, l, mid, tr[k].add);
    Update_add(k << 1 | 1, mid + 1, r, tr[k].add);
    tr[k].add = 0;
  }
  void Change_add(int L, int R, long long v, int l, int r, int k) {
    if (L > R) return;
    if (R < l) return;
    if (L > r) return;
    if (L <= l && R >= r) {
      Update_add(k, l, r, v);
      return;
    }
    int mid = l + r >> 1;
    Pushdown(k, l, r);
    if (L <= mid) Change_add(L, R, v, l, mid, k << 1);
    if (R > mid) Change_add(L, R, v, mid + 1, r, k << 1 | 1);
    Pushup(k);
  }
  long long Query_sum(int L, int R, int l, int r, int k) {
    if (L <= l && R >= r) return tr[k].sum;
    int mid = l + r >> 1;
    long long res = 0;
    Pushdown(k, l, r);
    if (L <= mid) res += Query_sum(L, R, l, mid, k << 1);
    if (R > mid) res += Query_sum(L, R, mid + 1, r, k << 1 | 1);
    return res;
  }
  void Add(int l, int r, int v) {
    int len = r - l + 1;
    int x = n - l + 1, y = r, p = min(x, y), q = max(x, y);
    Change_add(len, len, v * (l - r + len - 1), 0, n, 1);
    Change_add(p + 1, p + 1, -v * (l - r + len - 1), 0, n, 1);
    Change_add(len, p, v, 0, n, 1);
    Change_add(p + 1, p + 1, -v * (p - len + 1), 0, n, 1);
    if (p == x) {
      Change_add(p + 1, p + 1, v * (n - r + 1), 0, n, 1);
      Change_add(q + 1, q + 1, -v * (n - r + 1), 0, n, 1);
    } else {
      Change_add(p + 1, p + 1, v * l, 0, n, 1);
      Change_add(q + 1, q + 1, -v * l, 0, n, 1);
    }
    Change_add(q + 1, q + 1, v * (n + 1 - q), 0, n, 1);
    Change_add(q + 1, n, -v, 0, n, 1);
  }
  long long Query(int p) { return Query_sum(0, p, 0, n, 1); }
} ans;
struct seg {
  int l, r, x;
  seg(int L = 0, int R = 0, int X = 0) {
    l = L;
    r = R;
    x = X;
  }
  bool operator<(const seg &p) const { return l < p.l; }
};
map<int, set<seg> > mp;
set<seg> s;
void Get_ans() {
  map<int, int> last;
  for (int i = 1; i <= n; ++i) {
    mp[a[i]].insert(seg(i, i, a[i]));
    s.insert(seg(i, i, a[i]));
    int p = last[a[i]];
    if (p) ans.Add(p, i, 1);
    last[a[i]] = i;
  }
}
void work() { Get_ans(); }
void Change(int l, int r, int c) {
  seg p = *--s.upper_bound(seg(l));
  if (p.l < l) {
    s.erase(p);
    mp[p.x].erase(p);
    s.insert(seg(p.l, l - 1, p.x));
    mp[p.x].insert(seg(p.l, l - 1, p.x));
    s.insert(seg(l, p.r, p.x));
    mp[p.x].insert(seg(l, p.r, p.x));
  }
  p = *--s.upper_bound(seg(r));
  if (r < p.r) {
    s.erase(p);
    mp[p.x].erase(p);
    s.insert(seg(p.l, r, p.x));
    mp[p.x].insert(seg(p.l, r, p.x));
    s.insert(seg(r + 1, p.r, p.x));
    mp[p.x].insert(seg(r + 1, p.r, p.x));
  }
  vector<seg> tmp;
  set<int> col;
  for (set<seg>::iterator it = s.find(seg(l)); it != s.end() && it->r <= r;
       ++it) {
    tmp.push_back(*it);
    col.insert(it->x);
    set<seg> &ss = mp[it->x];
    if (ss.find(*it) != ss.begin()) ans.Add((--ss.find(*it))->r, it->l, -1);
    if (ss.find(*it) != --ss.end() && (++ss.find(*it))->l > r)
      ans.Add(it->r, (++ss.find(*it))->l, -1);
  }
  for (int vs = tmp.size(), i = 0; i < vs; ++i) {
    s.erase(tmp[i]);
    mp[tmp[i].x].erase(tmp[i]);
    if (i) ans.Add(tmp[i - 1].r, tmp[i].l, 1);
  }
  if (col.find(c) != col.end())
    col.erase(c);
  else {
    set<seg> &ss = mp[c];
    set<seg>::iterator t = ss.lower_bound(l);
    if (t == ss.begin() || t == ss.end())
      ;
    else {
      int v = t->l, u = (--t)->r;
      ans.Add(u, v, -1);
    }
  }
  for (set<int>::iterator it = col.begin(); it != col.end(); ++it) {
    int x = *it;
    set<seg> &ss = mp[x];
    set<seg>::iterator t = ss.lower_bound(l);
    if (t == ss.begin() || t == ss.end()) continue;
    int v = t->l, u = (--t)->r;
    ans.Add(u, v, 1);
  }
  s.insert(seg(l, r, c));
  set<seg>::iterator it = (mp[c].insert(seg(l, r, c))).first;
  set<seg> &ss = mp[c];
  if (it != ss.begin()) {
    set<seg>::iterator p = it;
    --p;
    ans.Add(p->r, it->l, 1);
  }
  if (it != --ss.end()) {
    set<seg>::iterator p = it;
    ++p;
    ans.Add(it->r, p->l, 1);
  }
}
void outo() {
  for (; cq--;) {
    int opt;
    scanf("%d", &opt);
    if (opt == 1) {
      int l, r, x;
      scanf("%d%d%d", &l, &r, &x);
      Change(l, r, x);
    } else {
      int x;
      scanf("%d", &x);
      printf("%lld\n", 1LL * x * (n - x + 1) - ans.Query(x));
    }
  }
}
int main() {
  into();
  work();
  outo();
  return 0;
}