#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int w = 0, x = 0;
  char c = getchar();
  while (!isdigit(c)) w |= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  return w ? -x : x;
}
namespace star {
const int maxn = 1e5 + 10;
int n, m;
struct sec {
  int l, r, w;
  sec(int l = 0, int r = 0, int w = 0) : l(l), r(r), w(w) {}
  inline bool operator<(const sec &b) const { return r < b.r; }
};
pair<long long, long long> e[maxn << 2];
void update(int x, int y, pair<int, int> k, int ro = 1, int l = 1, int r = n) {
  if (x > y) return;
  if (x == l and y == r)
    return e[ro].first += k.first, e[ro].second += k.second, void();
  e[(ro << 1)] = make_pair(e[(ro << 1)].first + e[ro].first,
                           e[(ro << 1)].second + e[ro].second),
           e[(ro << 1 | 1)] =
               make_pair(e[(ro << 1 | 1)].first + e[ro].first +
                             (((l + r) >> 1) + 1ll - l) * e[ro].second,
                         e[(ro << 1 | 1)].second + e[ro].second),
           e[ro] = make_pair(0, 0);
  if (y <= ((l + r) >> 1))
    update(x, y, k, (ro << 1), l, ((l + r) >> 1));
  else if (x > ((l + r) >> 1))
    update(x, y, k, (ro << 1 | 1), ((l + r) >> 1) + 1, r);
  else
    update(x, ((l + r) >> 1), k, (ro << 1), l, ((l + r) >> 1)),
        update(((l + r) >> 1) + 1, y,
               make_pair((((l + r) >> 1) + 1ll - x) * k.second + k.first,
                         k.second),
               (ro << 1 | 1), ((l + r) >> 1) + 1, r);
}
long long query(int x, int ro = 1, int l = 1, int r = n) {
  if (l == r) return e[ro].first;
  e[(ro << 1)] = make_pair(e[(ro << 1)].first + e[ro].first,
                           e[(ro << 1)].second + e[ro].second),
           e[(ro << 1 | 1)] =
               make_pair(e[(ro << 1 | 1)].first + e[ro].first +
                             (((l + r) >> 1) + 1ll - l) * e[ro].second,
                         e[(ro << 1 | 1)].second + e[ro].second),
           e[ro] = make_pair(0, 0);
  return x <= ((l + r) >> 1) ? query(x, (ro << 1), l, ((l + r) >> 1))
                             : query(x, (ro << 1 | 1), ((l + r) >> 1) + 1, r);
}
set<sec> st[maxn << 1];
inline void split(int x) {
  sec res = *st[0].lower_bound(sec(0, x, 0));
  if (res.r == x) return;
  st[0].erase(res), st[0].insert(sec(res.l, x, res.w)),
      st[0].insert(sec(x + 1, res.r, res.w));
  st[res.w].erase(res), st[res.w].insert(sec(res.l, x, res.w)),
      st[res.w].insert(sec(x + 1, res.r, res.w));
}
inline void del(sec x) {
  int l = x.l, r = x.r, w = x.w;
  auto it = st[w].find(x);
  int pre = it == st[w].begin() ? 0 : (--it)->r, a1 = l - pre, a2 = n - l + 1;
  if (a1 > a2) swap(a1, a2);
  if (l < r)
    update(1, n - r + 1, make_pair(-(r - l), 0)),
        update(n - r + 2, n - l, make_pair(-(r - 1 - l), 1));
  update(1, a1, make_pair(-1, -1)), update(a1 + 1, a2, make_pair(-a1, 0)),
      update(a2 + 1, a2 + a1 - 1, make_pair(-(a1 - 1), 1));
  st[0].erase(x), st[w].erase(x);
}
inline void insert(sec x) {
  int l = x.l, r = x.r, w = x.w;
  st[0].insert(x);
  auto it = st[w].insert(x).first;
  int pre = it == st[w].begin() ? 0 : (--it)->r, a1 = l - pre, a2 = n - l + 1;
  if (a1 > a2) swap(a1, a2);
  if (l < r)
    update(1, n - r + 1, make_pair(r - l, 0)),
        update(n - r + 2, n - l, make_pair(r - 1 - l, -1));
  update(1, a1, make_pair(1, 1)), update(a1 + 1, a2, make_pair(a1, 0)),
      update(a2 + 1, a2 + a1 - 1, make_pair(a1 - 1, -1));
}
inline int id(int x) {
  static unordered_map<int, int> mp;
  static int tot;
  if (!mp[x]) mp[x] = ++tot;
  return mp[x];
}
inline void work() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) insert(sec(i, i, id(read())));
  while (m--)
    if (read() == 1) {
      int l = read(), r = read(), w = id(read());
      split(l - 1), split(r);
      sec i, j;
      set<sec>::iterator it;
      while ((it = st[0].lower_bound(sec(0, l, 0))) != st[0].end() and
             it->l <= r) {
        int x = it->w;
        it = st[x].lower_bound(sec(0, l, 0));
        i = *it++;
        if (it != st[x].end())
          j = *it, del(j);
        else
          j = sec(0, 0, 0);
        del(i);
        if (j.w) insert(j);
      }
      it = st[w].lower_bound(sec(0, l, 0));
      if (it != st[w].end())
        j = *it, del(j);
      else
        j = sec(0, 0, 0);
      insert(sec(l, r, w));
      if (j.w) insert(j);
    } else
      printf("%lld\n", query(read()));
}
}  // namespace star
signed main() {
  star::work();
  return 0;
}
