#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
inline void write(long long x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const int N = 100005, Q = 100005;
int n;
struct BIT {
  long long d[N];
  inline void add(int x, long long v) {
    while (x <= n) d[x] += v, x += x & -x;
  }
  inline long long ask(int x) {
    static long long r;
    r = 0;
    while (x) r += d[x], x -= x & -x;
    return r;
  }
  inline void modify(int l, int r, long long v) {
    if (l > r) return;
    add(l, v), add(r + 1, -v);
  }
};
struct DataStructure {
  BIT T1, T2;
  inline void add(int l) { T1.modify(1, l, -1), T2.modify(1, l, l + 1); }
  inline void del(int l) { T1.modify(1, l, 1), T2.modify(1, l, -(l + 1)); }
  inline long long ask(int x) {
    long long r = x * T1.ask(x) + T2.ask(x);
    return r;
  }
} DS;
struct Line {
  int l, r;
  Line(int ll = -1, int rr = -1) { l = ll, r = rr; }
  bool operator<(Line w) const { return l < w.l; }
};
set<Line> T[N + Q];
inline void addval(int l, int r, int v) {
  if (v <= 0 || r < 0) return;
  static int L, R, l1, l2, l3;
  static set<Line>::iterator it2, it;
  it = T[v].find(Line(l, r));
  if (it->l != l || it->r != r) assert(0);
  if (it == T[v].begin())
    L = 0;
  else {
    it2 = it, --it2, L = it2->r;
  }
  it2 = it, ++it2;
  if (it2 == T[v].end())
    R = n + 1;
  else
    R = it2->l;
  R = n + 1;
  l2 = r - l + 1, l1 = l - L - 1, l3 = R - r - 1, DS.del(l1), DS.del(l3),
  DS.add(l1 + l2 + l3);
}
inline void devval(int l, int r, int v) {
  if (v <= 0 || r < 0) return;
  static int L, R, l1, l2, l3;
  static set<Line>::iterator it2, it;
  it = T[v].find(Line(l, r));
  if (it->l != l || it->r != r) assert(0);
  if (it == T[v].begin())
    L = 0;
  else {
    it2 = it, --it2, L = it2->r;
  }
  it2 = it, ++it2;
  if (it2 == T[v].end())
    R = n + 1;
  else
    R = it2->l;
  R = n + 1;
  l2 = r - l + 1, l1 = l - L - 1, l3 = R - r - 1, DS.add(l1), DS.add(l3),
  DS.del(l1 + l2 + l3);
}
inline void addc(int l, int r, int v) {
  if (v <= 0) return;
  static int l1, r1, l2, r2;
  l1 = r1 = l2 = r2 = -1;
  static set<Line>::iterator it;
  it = T[v].insert(Line(l, r)).first;
  if (it != T[v].begin()) {
    --it;
    l1 = it->l, r1 = it->r;
    ++it;
  }
  if ((++it) != T[v].end()) {
    l2 = it->l, r2 = it->r;
  }
  --it;
  T[v].erase(it);
  devval(l1, r1, v), devval(l2, r2, v);
  T[v].insert(Line(l, r));
  addval(l1, r1, v), addval(l2, r2, v);
  addval(l, r, v);
}
inline void devc(int l, int r, int v) {
  if (v <= 0) return;
  static int l1, r1, l2, r2;
  l1 = r1 = l2 = r2 = -1;
  static set<Line>::iterator it;
  it = T[v].find(Line(l, r));
  if (it->l != l || it->r != r) assert(0);
  if (it != T[v].begin()) {
    --it;
    l1 = it->l, r1 = it->r;
    ++it;
  }
  if ((++it) != T[v].end()) {
    l2 = it->l, r2 = it->r;
  }
  --it;
  devval(l1, r1, v), devval(l2, r2, v), devval(l, r, v);
  T[v].erase(T[v].find(Line(l, r)));
  addval(l1, r1, v), addval(l2, r2, v);
}
struct Node {
  int l, r, v;
  Node(int ll = -1, int rr = -1, int vv = -1) { l = ll, r = rr, v = vv; }
  bool operator<(Node w) const { return l < w.l; }
};
set<Node> S;
int v[N << 1], lv;
int q, a[N], qt[Q], ql[Q], qr[Q], qx[Q];
inline set<Node>::iterator spilt(int p) {
  static set<Node>::iterator it;
  it = S.upper_bound(Node(p));
  --it;
  if (it->l == p) return it;
  static int L, R, V;
  L = it->l, R = it->r, V = it->v;
  devc(L, R, V), S.erase(it);
  S.insert(Node(L, p - 1, V));
  addc(L, p - 1, V);
  addc(p, R, V);
  return S.insert(Node(p, R, V)).first;
}
inline void merge(int l, int r, int v) {
  if (v <= 0) return;
  static set<Node>::iterator it, it2;
  static bool fl, fr;
  static int L, R;
  fl = fr = 0, it = S.find(Node(l, r));
  if (it != S.begin()) {
    it2 = it, --it2;
    if (it2->v == v) fl = 1;
  }
  it2 = it, ++it2;
  if (it2 != S.end() && it2->v == v) fr = 1;
  if (!fl && !fr) return;
  while (fl || fr) {
    if (fl) {
      it2 = it, --it2;
      L = it2->l, R = r;
      devc(it->l, it->r, it->v), devc(it2->l, it2->r, it2->v);
      S.erase(it), S.erase(it2), fl = fr = 0,
                                 it = S.insert(Node(L, R, v)).first;
      l = L, r = R, addc(it->l, it->r, it->v);
      if (it != S.begin()) {
        it2 = it, --it2;
        if (it2->v == v) fl = 1;
      }
      it2 = it, ++it2;
      if (it2 != S.end() && it2->v == v) fr = 1;
      continue;
    }
    if (fr) {
      it2 = it, ++it2;
      L = l, R = it2->r;
      devc(it->l, it->r, it->v), devc(it2->l, it2->r, it2->v);
      S.erase(it), S.erase(it2), fl = fr = 0,
                                 it = S.insert(Node(L, R, v)).first;
      l = L, r = R, addc(it->l, it->r, it->v);
      if (it != S.begin()) {
        it2 = it, --it2;
        if (it2->v == v) fl = 1;
      }
      it2 = it, ++it2;
      if (it2 != S.end() && it2->v == v) fr = 1;
      continue;
    }
  }
}
inline void change(int l, int r, int v) {
  static set<Node>::iterator itl, itr, it;
  itr = spilt(r + 1), itl = spilt(l);
  for (it = itl; it != itr; ++it) devc(it->l, it->r, it->v);
  S.erase(itl, itr);
  S.insert(Node(l, r, v)), addc(l, r, v);
  if (v) merge(l, r, v);
}
int main() {
  int i;
  read(n), read(q);
  for (i = 1; i <= n; ++i) read(a[i]), v[i] = a[i];
  lv = n;
  for (i = 1; i <= q; ++i) {
    read(qt[i]);
    if (qt[i] == 1) {
      read(ql[i]), read(qr[i]), read(qx[i]);
      v[++lv] = qx[i];
    } else
      read(qx[i]);
  }
  sort(v + 1, v + lv + 1), lv = unique(v + 1, v + lv + 1) - (v + 1);
  for (i = 1; i <= n; ++i) a[i] = lower_bound(v + 1, v + lv + 1, a[i]) - v;
  for (i = 1; i <= q; ++i)
    if (qt[i] == 1) qx[i] = lower_bound(v + 1, v + lv + 1, qx[i]) - v;
  S.insert(Node(0, 0, 0));
  S.insert(Node(n + 1, n + 1, 0));
  for (i = 1; i <= n; ++i) S.insert(Node(i, i, 0));
  for (i = 1; i <= n; ++i) change(i, i, a[i]);
  for (i = 1; i <= q; ++i) {
    if (qt[i] == 2) {
      write(DS.ask(qx[i])), putchar('\n');
      continue;
    }
    change(ql[i], qr[i], qx[i]);
  }
  return 0;
}
