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

Solution:
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class P988E
{
	public static int min;
	
	public static void main(String[] args)
	{
		FastScanner in = new FastScanner(System.in);
		String s = in.next();
		if (s.length() < 2) {
			if (s.equals("0"))
				System.out.println(0);
			else
				System.out.println(-1);
			return;
		}
		if (s.endsWith("00") || s.endsWith("25") || s.endsWith("50") || s.endsWith("75")) {
			System.out.println(0);
			return;
		}
		min = -1;
		end00(s);
		end(s, '2', '5');
		end(s, '5', '0');
		end(s, '7', '5');
		System.out.println(min);
	}
	
	public static void end00(String s)
	{
		int a = s.lastIndexOf('0');
		if (a == -1)
			return;
		int b = s.lastIndexOf('0', a - 1);
		if (b == -1)
			return;
		int moves = s.length() - 1 - a + s.length() - 2 - b;
		if (min == -1 || moves < min)
			min = moves;
	}
	
	public static void end(String s, char fromLast, char last)
	{
		int a = s.lastIndexOf(last);
		int b = s.lastIndexOf(fromLast);
		if (a == -1 || b == -1)
			return;
		int moves = 0;
		if ((a == 0 || b == 0) && s.charAt(1) == '0') {
			int firstNonZero = -1;
			for (int i = 2; i < s.length(); i++) {
				if (s.charAt(i) != '0' && i != a && i != b) {
					firstNonZero = i;
					break;
				}
			}
			if (firstNonZero == -1)
				return;
			moves = firstNonZero;
			s = s.substring(firstNonZero, firstNonZero + 1) + s.substring(0, firstNonZero) + s.substring(firstNonZero + 1);
			a = s.lastIndexOf(last);
			b = s.lastIndexOf(fromLast);
		}
		moves += s.length() - 1 - a + s.length() - 2 - b;
		if (a < b)
			moves++;
		if (min == -1 || moves < min)
			min = moves;
	}
	
	/**
	 * Source: Matt Fontaine
	 */
	public static class FastScanner
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream)
		{
			this.stream = stream;
		}

		int read()
		{
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				} catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c)
		{
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}

		public String next()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}