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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class A 
{	

	public static void main(String args[]) throws IOException
	{
		Scanner sc=new Scanner(System.in);
		PrintWriter wr=new  PrintWriter(System.out);
		String s=sc.next();
		if(s.length()==1) {
			System.out.println(-1);return;
		}
		int ans=10000;
		if(s.contains("5")&& s.contains("0")) {
			int idx1=s.lastIndexOf('5');
			int idx2=s.lastIndexOf('0');
			
			if(idx1<idx2) 
				ans=Math.min(ans, 2*s.length()-idx1-idx2-3);
			else
				ans=Math.min(ans, 2*s.length()-idx1-idx2-2 );
			
			
		}
	
		if(s.contains("7")&& s.contains("5")) {
			int idx1=s.lastIndexOf('7');
			int idx2=s.lastIndexOf('5');
			int c=0;
			if(idx1==0||idx2==0) {
				for(int i=1;i<s.length() ;i++) {
					if(s.charAt(i)!='0')break;
					else c++;
				}
				
			}
			if(idx1<idx2) 
				ans=Math.min(ans, 2*s.length()-idx1-idx2-3+c);
			else
				ans=Math.min(ans, 2*s.length()-idx1-idx2-2+c);
			
		}
		
		if(s.contains("2")&& s.contains("5")) {
			int idx1=s.lastIndexOf('2');
			int idx2=s.lastIndexOf('5');
			int c=0;
			if(idx1==0||idx2==0) {
				for(int i=1;i<s.length() ;i++) {
					if(s.charAt(i)!='0')break;
					else c++;
					
				}
				
			}
			if(idx1<idx2) 
				ans=Math.min(ans, 2*s.length()-idx1-idx2-3+c);
			else
				ans=Math.min(ans, 2*s.length()-idx1-idx2-2+c );
			
			
		}
		
		if(s.contains("0")&& s.indexOf("0")!=s.lastIndexOf("0")) {
			
			int idx1=-1;
			int idx2=-1;
			for(int i=s.length()-1;i>=0;i--) {
				if(s.charAt(i)=='0') {
					if(idx1==-1)idx1=i;
					else if(idx2==-1)idx2=i;
				}
				if(idx1!=-1 && idx2!=-1)break;
			}
			ans=Math.min(ans, 2*s.length()-idx1-idx2-3);
			
		}
		
		System.out.println(ans==10000 ?-1:ans);
		wr.close();
		
		
	}

}
class Scanner 
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException 
	{
		while (st == null || !st.hasMoreTokens()) 
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}
	
	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}
	
	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}
	
	public boolean ready() throws IOException {return br.ready();}


}