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 PYTHON3):

Solution:
class Problem:
	def solve(self, s):
		ans = -1
		n = len(s)
		for i in range(n):
			for j in range(n):
				if i != j:
					c1 = c2 = 0
					t, c1 = self.move_end(s, i, j)
					if t[0] == "0":
						k = self.find_nonzero(t)
						t, c2 = self.move_begin(t, k)
					if self.ok(t):
						ans = self.best(ans, c1+c2)
					# print("i", i, "j", j, "t", t)
		return ans

	def move_end(self, s, i, j):
		# i < j          j < i       
		# a i b j c      a j b i c
		# a i b c j (j)  a b i c j (j)
		# a b c i j (i)  a b c i j (i)
		if j < i: i -= 1
		t = s
		t, c1 = self.move_char(t, j, len(t)-1)
		t, c2 = self.move_char(t, i, len(t)-2)
		return t, c1 + c2
	
	def move_begin(self, s, i):
		return self.move_char(s, i, 0)

	def move_char(self, s, i:"index from", j:"index to"):
		l = list(s)
		count = 0
		while i != j:
			count += 1
			if i < j:
				l[i], l[i+1] = l[i+1], l[i]
				i += 1
			else:
				l[i-1], l[i] = l[i], l[i-1]
				i -= 1
		return "".join(l), count
	
	def ok(self, s):
		return s[0] != "0" and int(s) % 25 == 0
	
	def find_nonzero(self, s):
		found = -1
		for i in range(len(s)):
			if s[i] != "0":
				found = i
				break
		return found
		
	def best(self, a, b):
		if a == -1: return b
		if b == -1: return a
		return a if a<b else b

s = input()
ans = Problem().solve(s)
print(ans)
exit()

assert(0 == Problem().solve("100"))
assert(1 == Problem().solve("52"))
assert(4 == Problem().solve("5071"))
assert(1 == Problem().solve("705"))
assert(-1 == Problem().solve("1241367"))
assert(2 == Problem().solve("507"))
assert(1 == Problem().solve("17010"))
assert(6 == Problem().solve("52231"))
assert(5 == Problem().solve("50267"))
print("ok")