input_line = raw_input()
n = int(input_line.split(" ")[0])
m = int(input_line.split(" ")[1])

input_line = raw_input()
a = map(int, input_line.split(" "))

ope = []
for i in range(m):
    input_line = raw_input()
    ope.append(map(int, input_line.split(" ")))

print a

for t, l, r, x in ope:
    if t == 1:
        for i in range(l-1, r):
            a[i] -= x * (a[i] > x)
    else:
        print a[l-1:r].count(x)
