Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya has an array consisting of *n* numbers. He wants to perform *m* operations of two types: 
 -  add *l* *r* *d* — add an integer *d* to all elements whose indexes belong to the interval from *l* to *r*, inclusive (1 ≤ *l* ≤ *r* ≤ *n*, 1 ≤ *d* ≤ 10<sup class="upper-index">4</sup>); -  count *l* *r* — find and print on the screen how many lucky numbers there are among elements with indexes that belong to the interval from *l* to *r* inclusive (1 ≤ *l* ≤ *r* ≤ *n*). Each lucky number should be counted as many times as it appears in the interval. 
Petya has a list of all operations. The operations are such that after all additions the array won't have numbers that would exceed 10<sup class="upper-index">4</sup>. Help Petya write a program that would perform these operations.
The first line contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">5</sup>) — the number of numbers in the array and the number of operations correspondingly. The second line contains *n* positive integers, none of which exceeds 10<sup class="upper-index">4</sup> — those are the array numbers. Next *m* lines contain operations, one per line. They correspond to the description given in the statement.

It is guaranteed that after all operations are fulfilled each number in the array will not exceed 10<sup class="upper-index">4</sup>.
import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter, deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines

class Lazy_Segment_Tree:
    def __init__(self,N,f,e,f_act,e_act,operate,lst=None):
        self.N=N
        self.f=f
        self.e=e
        self.f_act=f_act
        self.e_act=e_act
        self.operate=operate
        self.segment_tree=[self.e]*(self.N+self.N)
        self.segment_tree_act=[self.e_act]*(self.N+self.N)
        if lst!=None:
            for i,x in enumerate(lst):
                self.segment_tree[i+self.N]=x
            for i in range(self.N-1,0,-1):
                self.segment_tree[i]=self.f(self.segment_tree[i<<1],self.segment_tree[i<<1|1])
            self.segment_tree_act=[self.e_act]*(self.N+self.N)

    def __getitem__(self,i):
        if type(i) is int:
            if -self.N<=i<0:
                i+=self.N*2
            elif 0<=i<self.N:
                i+=self.N
            else:
                raise IndexError('list index out of range')
            self.Propagate_Above(i)
            self.Recalculate_Above(i)
            return self.Operate_At(i)
        else:
            a,b,c=i.start,i.stop,i.step
            if a==None or a<-self.N:
                a=self.N
            elif self.N<=a:
                a=self.N*2
            elif a<0:
                a+=self.N*2
            else:
                a+=self.N
            if b==None or self.N<=b:
                b=self.N*2
            elif b<-self.N:
                b=self.N
            elif b<0:
                b+=self.N*2
            else:
                b+=self.N
            return self.segment_tree[slice(a,b,c)]

    def __setitem__(self,i,x):
        if -self.N<=i<0:
            i+=self.N*2
        elif 0<=i<self.N:
            i+=self.N
        else:
            raise IndexError('list index out of range')
        self.Propagate_Above(i)
        self.segment_tree[i]=x
        self.segment_tree_act[i]=self.e_act
        self.Recalculate_Above(i)

    def Operate_At(self,i):
        return self.operate(self.segment_tree[i],self.segment_tree_act[i])

    def Propagate_At(self,i):
        self.segment_tree[i]=self.Operate_At(i)
        self.segment_tree_act[i<<1]=self.f_act(self.segment_tree_act[i<<1],self.segment_tree_act[i])
        self.segment_tree_act[i<<1|1]=self.f_act(self.segment_tree_act[i<<1|1],self.segment_tree_act[i])
        self.segment_tree_act[i]=self.e_act

    def Propagate_Above(self,i):
        H=i.bit_length()-1
        for h in range(H,0,-1):
            self.Propagate_At(i>>h)

    def Recalculate_Above(self,i):
        while i>1:
            i>>=1
            self.segment_tree[i]=self.f(self.Operate_At(i<<1),self.Operate_At(i<<1|1))

    def Build(self,lst):
        for i,x in enumerate(lst):
            self.segment_tree[i+self.N]=x
        for i in range(self.N-1,0,-1):
            self.segment_tree[i]=self.f(self.segment_tree[i<<1],self.segment_tree[i<<1|1])
        self.segment_tree_act=[self.e_act]*(self.N+self.N)

    def Fold(self,L=None,R=None):
        if L==None:
            L=self.N
        else:
            L+=self.N
        if R==None:
            R=self.N*2
        else:
            R+=self.N
        self.Propagate_Above(L//(L&-L))
        self.Propagate_Above(R//(R&-R)-1)
        vL=self.e
        vR=self.e
        while L<R:
            if L&1:
                vL=self.f(vL,self.Operate_At(L))
                L+=1
            if R&1:
                R-=1
                vR=self.f(self.Operate_At(R),vR)
            L>>=1
            R>>=1
        return self.f(vL,vR)

    def Fold_Index(self,L=None,R=None):
        if L==None:
            L=self.N
        else:
            L+=self.N
        if R==None:
            R=self.N*2
        else:
            R+=self.N
        if L==R:
            return None
        x=self.Fold(L-self.N,R-self.N)
        while L<R:
            if L&1:
                if self.segment_tree[L]==x:
                    i=L
                    break
                L+=1
            if R&1:
                R-=1
                if self.segment_tree[R]==x:
                    i=R
                    break
            L>>=1
            R>>=1
        while i<self.N:
            if self.segment_tree[i]==self.segment_tree[i<<1]:
                i<<=1
            else:
                i<<=1
                i|=1
        i-=self.N
        return i

    def Operate_Range(self,a,L=None,R=None):
        if L==None:
            L=self.N
        else:
            L+=self.N
        if R==None:
            R=self.N*2
        else:
            R+=self.N
        L0=L//(L&-L)
        R0=R//(R&-R)-1
        self.Propagate_Above(L0)
        self.Propagate_Above(R0)
        while L<R:
            if L&1:
                self.segment_tree_act[L]=self.f_act(self.segment_tree_act[L],a)
                L+=1
            if R&1:
                R-=1
                self.segment_tree_act[R]=self.f_act(self.segment_tree_act[R],a)
            L>>=1
            R>>=1
        self.Recalculate_Above(L0)
        self.Recalculate_Above(R0)

    def Update(self):
        for i in range(1,self.N):
            self.Propagate_At(i)
        for i in range(self.N,self.N*2):
            self.segment_tree[i]=self.Operate_At(i)
            self.segment_tree_act[i]=self.e_act
        for i in range(self.N-1,0,-1):
            self.segment_tree[i]=self.f(self.segment_tree[i<<1],self.segment_tree[i<<1|1])

    def Bisect_Right(self,L=None,f=None):
        if L==self.N:
            return self.N
        if L==None:
            L=0
        if f(self.Fold(L,self.N)):
            return self.N
        L+=self.N
        v=self.e
        while True:
            while L%2==0:
                L>>=1
            self.Propagate_Above(L)
            vv=self.f(v,self.Operate_At(L))
            if f(vv):
                v=vv
                L+=1
            else:
                while L<self.N:
                    L<<=1
                    self.Propagate_Above(L)
                    vv=self.f(v,self.Operate_At(L))
                    if f(vv):
                        v=vv
                        L+=1
                return L-self.N

    def __str__(self):
        import copy
        segment_tree=copy.deepcopy(self.segment_tree)
        segment_tree_act=copy.deepcopy(self.segment_tree_act)
        for i in range(1,self.N):
            segment_tree[i]=self.operate(segment_tree[i],segment_tree_act[i])
            segment_tree_act[i<<1]=self.f_act(segment_tree_act[i<<1],segment_tree_act[i])
            segment_tree_act[i<<1|1]=self.f_act(segment_tree_act[i<<1|1],segment_tree_act[i])
            segment_tree_act[i]=self.e_act
        for i in range(self.N,self.N*2):
            segment_tree[i]=self.operate(segment_tree[i],segment_tree_act[i])
            segment_tree_act[i]=self.e_act
        for i in range(self.N-1,0,-1):
            segment_tree[i]=self.f(segment_tree[i<<1],segment_tree[i<<1|1])
        return '['+', '.join(map(str,[self.operate(x,a) for x,a in zip(segment_tree[self.N:],segment_tree_act[self.N:])]))+']'

class Segment_Tree:
    def __init__(self,N,f,e,lst=None):
        self.f=f
        self.e=e
        self.N=N
        if lst==None:
            self.segment_tree=[self.e]*2*self.N
        else:
            assert len(lst)<=self.N
            self.segment_tree=[self.e]*self.N+[x for x in lst]+[self.e]*(N-len(lst))
            for i in range(self.N-1,0,-1):
                self.segment_tree[i]=self.f(self.segment_tree[i<<1],self.segment_tree[i<<1|1])

    def __getitem__(self,i):
        if type(i)==int:
            if -self.N<=i<0:
                return self.segment_tree[i+self.N*2]
            elif 0<=i<self.N:
                return self.segment_tree[i+self.N]
            else:
                raise IndexError('list index out of range')
        else:
            a,b,c=i.start,i.stop,i.step
            if a==None:
                a=self.N
            else:
                a+=self.N
            if b==None:
                b=self.N*2
            else:
                b+=self.N
            return self.segment_tree[slice(a,b,c)]

    def __setitem__(self,i,x):
        if -self.N<=i<0:
            i+=self.N*2
        elif 0<=i<self.N:
            i+=self.N
        else:
            raise IndexError('list index out of range')
        self.segment_tree[i]=x
        while i>1:
            i>>= 1
            self.segment_tree[i]=self.f(self.segment_tree[i<<1],self.segment_tree[i<<1|1])

    def Build(self,lst):
        for i,x in enumerate(lst,self.N):
            self.segment_tree[i]=x
        for i in range(self.N-1,0,-1):
            self.segment_tree[i]=self.f(self.segment_tree[i<<1],self.segment_tree[i<<1|1])

    def Fold(self,L=None,R=None):
        if L==None:
            L=self.N
        else:
            L+=self.N
        if R==None:
            R=self.N*2
        else:
            R+=self.N
        vL=self.e
        vR=self.e
        while L<R:
            if L&1:
                vL=self.f(vL,self.segment_tree[L])
                L+=1
            if R&1:
                R-=1
                vR=self.f(self.segment_tree[R],vR)
            L>>=1
            R>>=1
        return self.f(vL,vR)

    def Fold_Index(self,L=None,R=None):
        if L==None:
            L=self.N
        else:
            L+=self.N
        if R==None:
            R=self.N*2
        else:
            R+=self.N
        if L==R:
            return None
        x=self.Fold(L-self.N,R-self.N)
        while L<R:
            if L&1:
                if self.segment_tree[L]==x:
                    i=L
                    break
                L+=1
            if R&1:
                R-=1
                if self.segment_tree[R]==x:
                    i=R
                    break
            L>>=1
            R>>=1
        while i<self.N:
            if self.segment_tree[i]==self.segment_tree[i<<1]:
                i<<=1
            else:
                i<<=1
                i|=1
        i-=self.N
        return i

    def Bisect_Right(self,l=None,f=None):
        if l==self.N:
            return self.N
        if l==None:
            l=0
        if f(self.Fold(l,self.N)):
            return self.N
        l+=self.N
        v=self.e
        while True:
            while l%2==0:
                l>>=1
            vv=self.f(v,self.segment_tree[l])
            if f(vv):
                v=vv
                l+=1
            else:
                while l<self.N:
                    l<<=1
                    vv=self.f(v,self.segment_tree[l])
                    if f(vv):
                        v=vv
                        l+=1
                return l-self.N

    def Bisect_Left(self,r=None,f=None):
        if r==0:
            return 0
        if r==None:
            r=self.N
        if f(self.Fold(0,r)):
            return 0
        r+=self.N
        v=self.e
        while True:
            r-=1
            while r>1 and r%2:
                r>>=1
            vv=self.f(self.segment_tree[r],v)
            if f(vv):
                v=vv
            else:
                while r<self.N:
                    r=2*r+1
                    vv=self.f(self.segment_tree[r],v)
                    if f(vv):
                        v=vv
                        r-=1
                return r+1-self.N

    def __str__(self):
        return '['+', '.join(map(str,self.segment_tree[self.N:]))+']'

lucky=[]
for i in range(1,10**5):
    s=str(i)
    if len(s)==s.count("4")+s.count("7"):
        lucky.append(int(s))
N,M=map(int,readline().split())
A=list(map(int,readline().split()))
inf=1<<30
ST=[0]*N
for i in range(N):
    a=str(A[i])
    if len(a)==a.count("4")+a.count("7"):
        ST[i]=1
ST=Segment_Tree(N,lambda x,y:x+y,0,ST)
LST=Lazy_Segment_Tree(N,min,inf,lambda a,b:a+b,0,lambda x,a:x+a,A)
query=[]
for i in range(M):
    data=iter(readline().split())
    if next(data)=="add":
        l,r,d=map(int,data)
        l-=1
        for lu in lucky:
            a=l
            b=LST.Bisect_Right(a,lambda x:x>lu)
            while b<r:
                if LST.Fold(b,b+1)==lu:
                    ST[b]=0
                a=b+1
                b=LST.Bisect_Right(a,lambda x:x>lu)
        LST.Operate_Range(d,l,r)
        for lu in lucky:
            a=l
            b=LST.Bisect_Right(a,lambda x:x>lu)
            while b<r:
                if LST.Fold(b,b+1)==lu:
                    ST[b]=1
                a=b+1
                b=LST.Bisect_Right(a,lambda x:x>lu)
    else:
        l,r=map(int,data)
        l-=1
        ans=ST.Fold(l,r)
        print(ans)