— I... I survived.

— Welcome home, Chtholly.

— I kept my promise...

— I made it... I really made it!

After several days of fighting, Chtholly Nota Seniorious miraculously returned from the fierce battle.

As promised, Willem is now baking butter cake for her.

However, although Willem is skilled in making dessert, he rarely bakes butter cake.

This time, Willem made a big mistake — he accidentally broke the oven!

Fortunately, Chtholly decided to help him.

Willem puts *n* cakes on a roll, cakes are numbered from 1 to *n*, the *i*-th cake needs *a*<sub class="lower-index">*i*</sub> seconds of baking.

Willem needs Chtholly to do *m* operations to bake the cakes.

Operation 1: 1 *l* *r* *x*

Willem asks Chtholly to check each cake in the range [*l*, *r*], if the cake needs to be baked for more than *x* seconds, he would bake it for *x* seconds and put it back in its place. More precisely, for every *i* in range [*l*, *r*], if *a*<sub class="lower-index">*i*</sub> is strictly more than *x*, *a*<sub class="lower-index">*i*</sub> becomes equal *a*<sub class="lower-index">*i*</sub> - *x*.

Operation 2: 2 *l* *r* *x*

Willem asks Chtholly to count the number of cakes in the range [*l*, *r*] that needs to be cooked for exactly *x* seconds. More formally you should find number of such *i* in range [*l*, *r*], that *a*<sub class="lower-index">*i*</sub> = *x*.
The first line contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">5</sup>).

The second line contains *n* integers, *i*-th of them is *a*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">5</sup>).

The next *m* lines are the *m* operations described above. It is guaranteed that 1 ≤ *l* ≤ *r* ≤ *n* and 1 ≤ *x* ≤ 10<sup class="upper-index">5</sup>.
none
# 读入 n 和 m
n, m = map(int, input().split())
# 读入序列 a
a = list(map(int, input().split()))
# 定义分块大小
B = int(n ** 0.5)
# 定义块数
K = (n + B - 1) // B
# 定义每个块的双向链表
block = [[] for _ in range(K)]
# 定义每个块的标记
tag = [0] * K
# 定义每个块内每个值出现的次数
cnt = [{} for _ in range(K)]
# 初始化每个块
for i in range(n):
    # 计算所属的块编号
    k = i // B
    # 将 a[i] 插入到双向链表中，并保持有序
    j = len(block[k]) - 1
    while j >= 0 and block[k][j] > a[i]:
        j -= 1
    block[k].insert(j + 1, a[i])
    # 更新 cnt[k][a[i]]
    cnt[k][a[i]] = cnt[k].get(a[i], 0) + 1

# 处理 m 次操作
for _ in range(m):
    # 读入操作类型和参数
    op, l, r, x = map(int, input().split())
    # 将 l 和 r 转换为从 0 开始的下标
    l -= 1
    r -= 1
    # 计算涉及到的块编号范围
    kl = l // B
    kr = r // B
    # 如果是第一种操作，即将区间 [l,r] 内所有大于 x 的数减去 x
    if op == 1:
        # 遍历涉及到的每个块
        for k in range(kl, kr + 1):
            # 如果是完整的块，直接打标记即可
            if l <= k * B and (k + 1) * B - 1 <= r:
                tag[k] += x
            # 否则需要重构这个块，并更新 cnt[k]
            else:
                # 创建一个新的空链表和空字典
                new_block = []
                new_cnt = {}
                # 遍历这个块内的每个值
                for v in block[k]:
                    # 将 v 减去标记
                    v -= tag[k]
                    # 如果 v 大于 x，就将 v 减去 x，并插入到新链表中
                    if v > x:
                        v -= x
                        new_block.append(v)
                        new_cnt[v] = new_cnt.get(v, 0) + cnt[k][v + tag[k]]
                    # 否则就将 v 加上 x，并插入到新链表的合适位置
                    else:
                        v += x
                        j = len(new_block) - 1
                        while j >= 0 and new_block[j] > v:
                            j -= 1
                        new_block.insert(j + 1, v)
                        new_cnt[v] = new_cnt.get(v, 0) + cnt[k][v - tag[k] + x]
                # 将新链表和新字典赋值给原来的块
                block[k] = new_block
                cnt[k] = new_cnt
                # 将标记清零
                tag[k] = 0
    # 如果是第二种操作，即查询区间 [l,r] 内值为 x 的数的个数
    else:
        # 初始化答案为 0
        ans = 0
        # 遍历涉及到的每个块
        for k in range(kl, kr + 1):
            # 如果是完整的块，直接查询 cnt[k][x + tag[k]]
            if l <= k * B and (k + 1) * B - 1 <= r:
                ans += cnt[k].get(x + tag[k], 0)
            # 否则需要遍历这个块内的每个值，判断是否等于 x + tag[k]
            else:
                for v in block[k]:
                    if l <= k * B + block[k].index(v) <= r and v == x + tag[k]:
                        ans += cnt[k][v]
        # 输出答案
        print(ans)