Chef 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.

Chef has a positive integer N. He can apply any of the following operations as many times as he want in any order:

-  Add 1 to the number N.

-  Take some digit of N and replace it by any non-zero digit.

-  Add any non-zero leading digit to N.

Find the minimum number of operations that is needed for changing N to the lucky number.

-----Input-----
The first line contains a single positive integer T, the number of test cases. T test cases follow. The only line of each test case contains a positive integer N without leading zeros. 

-----Output-----
For each T test cases print one integer, the minimum number of operations that is needed for changing N to the lucky number.

-----Constraints-----

1 ≤ T ≤ 10

1 ≤ N < 10100000

-----Example-----
Input:
3
25
46
99

Output:
2
1
2

Starter code:

Solutions:
# cook your dish here
for _ in range(0,int(input())):
    n=input().strip()
    x=n.count('4')
    y=n.count('7')
    print(len(n)-x-y)
        

# cook your dish here
for _ in range(int(input())):
    N=list(input().strip())
    a=N.count('4')
    b=N.count('7')
    print(len(N)-a-b)

t = int(input())
while t :
    t -= 1 
    n = input().strip()
    x = n.count('4')
    y = n.count('7')
    print(len(n)-x-y)

for _ in range(int(input())):
    N=list(input().strip())
    a=N.count('4')
    b=N.count('7')
    print(len(N)-a-b)


for _ in range(int(input())):
    N=list(input().strip())
    a=N.count('4')
    b=N.count('7')
    print(len(N)-a-b)

# cook your dish here
t=int(input())
for _ in range(t):
    n=input().strip()
    cnt=0
    
    for i in n:
        if i!='4' and i!='7':
            cnt+=1
            
    print(cnt)

for _ in range(int(input())):
    n = input().strip()
    count = 0
    for i in n:
        if i != '4' and i != '7':
            count+=1
    print(count)

for _ in range(int(input())):
    st=input().strip()
    an=0
    for ch in st:
        if ch=="4" or ch=="7":
            continue
        else:
            an+=1
    print(an)

for _ in range(int(input())):
    n = input().strip()
    count = 0
    for i in n:
        if i != '4' and i != '7':
            count+=1
    print(count)

T = int(input())
ans = []

for _ in range(T):
    N = input().strip()

    count = 0
    for i in N:
        if(i!='4' and i!='7'):
            count += 1
    ans.append(count)

for i in ans:
    print(i)


tests = int(input())
for test in range(tests):
    n = input().strip()
    length = len(n)
    steps = length - (n.count('4') + n.count('7'))
    print(steps)

# cook your dish here
tests = int(input())
for test in range(tests):
    n = input().strip()
    length = len(n)
    steps = length - (n.count('4') + n.count('7'))
    print(steps)

t = int(input())
while t > 0:
    n = input().strip()
    f = n.count('4')
    s = n.count('7')
    print(len(n) - (f + s))
    t = t - 1

t=int(input())
for i in range(t):
    n=input().strip()
    sev=n.count('7')
    four=n.count('4')
    print(len(n)-(sev+four))
    


for _ in range(int(input())):
    n = input().strip()
    seven , four = n.count('7'),n.count('4')
    x =seven + four
    print(len(n)- x)


for _ in range(int(input())):
    n=input().strip()
    print(len(n)-(n.count('4')+n.count('7')))


T = int(input())
for i in range(0,T):
    N = input().strip()
    cnt=0
    for j in range(0,len(N)):
        if N[j]!='4' and N[j]!='7':
            cnt +=1
    print(cnt)


# cook your dish here
for _ in range(int(input())):
    n=input().strip()
    a=0
    for i in n:
        if i!='4' and i!='7':
            a+=1 
    print(a)
    

# cook your dish here
for _ in range(int(input())):
    s = input().strip()
    ans = 0
    for i in s:
        if i != '4' and i != '7':
            ans += 1
    print(ans)

for i in range(int(input())):
    count = 0
    num = input().strip()
    for i in num:
        if i!= '4' and i!='7':
            count+=1
    print(count)



# cook your dish here
for _ in range(int(input())):
    N=input().strip()
    c=0
    for i in N:
        if i!='4' and i!='7':
            c+=1
    
    print(c)
    
        


# cook your dish here
for _ in range(int(input())):
    N=input().strip()
    c=0
    for i in N:
        if i!='4' and i!='7':
            c+=1
    
    print(c)
    
        


# cook your dish here
t = int(input())
while t:
    n = input().strip()
    c = 0
    for i in n:
        if i != '7' and i != '4':
            c += 1
    print(c)
    t -= 1

# cook your dish here
t = int(input())
while t:
    n = input().strip()
    c = 0
    for i in n:
        if i != '7' and i != '4':
            c += 1
    print(c)
    t -= 1