Problem: You are given an integer n from 1 to 10^{18} without leading zeroes.

In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes.

What is the minimum number of moves you have to make to obtain a number that is divisible by 25? Print -1 if it is impossible to obtain a number that is divisible by 25.

Input

The first line contains an integer n (1 ≤ n ≤ 10^{18}). It is guaranteed that the first (left) digit of the number n is not a zero.

Output

If it is impossible to obtain a number that is divisible by 25, print -1. Otherwise print the minimum number of moves required to obtain such number.

Note that you can swap only adjacent digits in the given number.

Examples

Input

5071


Output

4


Input

705


Output

1


Input

1241367


Output

-1

Note

In the first example one of the possible sequences of moves is 5071 → 5701 → 7501 → 7510 → 7150.

Solution (in PYTHON):

Solution:
s = str(raw_input())
i0 = 0
i2 = 0
i5 = 0
i7 = 0
tmp_a = 999999999
tmp_b = 999999999
tmp_c = 999999999
tmp_d = 999999999
poz0_1 = -1
poz0_2 = -1
poz2 = -1
poz5 = -1
poz7 = -1
if len(s)==1:
    if s[0]=='0':
        print '0'
        exit(0)
    else:
        print '-1'
        exit(0)
if int(s[-2]+s[-1])%25==0:
    print '0'
    exit(0)
for x in range(len(s)-1,-1,-1):
    if s[x]=='0':
        if poz0_1 == -1:
            poz0_1 = x
        elif poz0_2 == -1:
            poz0_2 = x
        i0+=1
    elif s[x]=='2':
        if poz2 == -1:
            poz2 = x
        i2+=1
    elif s[x]=='5':
        if poz5 == -1:
            poz5 = x
        i5+=1
    elif s[x]=='7':
        if poz7 == -1:
            poz7 = x
        i7+=1
if i0 >= 2:
    tmp_a = len(s)-poz0_1-1 + len(s)-poz0_2-2
if (i2>=1 and i5>=1):
    if poz2>poz5:
        tmp_b = len(s)-poz2-1 + len(s)-poz5-1
    else:
        tmp_b = len(s) - poz5 - 1 + len(s) - poz2 - 2
    tmp_s = list(s)
    tmp_s.reverse()
    tmp_s.remove('5')
    tmp_s.remove('2')
    tmp_s.reverse()
    for x in range(0,len(tmp_s),+1):
        if tmp_s[x]!='0':
            tmp_b+=x
            break
if (i5>=1 and i0>=1):
    if poz0_1>poz5:
        tmp_c = len(s)-poz5-2 + len(s)-poz0_1-1
    else:
        tmp_c = len(s) - poz5 - 1 + len(s) - poz0_1 - 1
    tmp_s = list(s)
    tmp_s.reverse()
    tmp_s.remove('5')
    tmp_s.remove('0')
    tmp_s.reverse()
    for x in range(0, len(tmp_s), +1):
        if tmp_s[x] != '0':
            tmp_c += x
            break
if i5>=1 and i7>=1:
    if poz5>poz7:
        tmp_d = len(s)-poz5-1 + len(s)-poz7-2
    else:
        tmp_d = len(s) - poz5 - 1 + len(s) - poz7 - 1
    tmp_s = list(s)
    tmp_s.reverse()
    tmp_s.remove('7')
    tmp_s.remove('5')
    tmp_s.reverse()
    for x in range(0, len(tmp_s), +1):
        if tmp_s[x] != '0':
            tmp_d += x
            break
if tmp_a == tmp_b == tmp_c == tmp_d == 999999999:
    print '-1'
else:
    t_wyn = [tmp_a,tmp_b,tmp_c,tmp_d]
    #print t_wyn
    print min(t_wyn)