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

public class B {
	
public static int solve(String s,String num)
{
	int idx1=num.lastIndexOf(s.charAt(0));
	int idx2=num.lastIndexOf(s.charAt(1));
	if(s.equals("00"))
	{
		idx1=-1;
		for(int i=0;i<idx2;i++)
			if(num.charAt(i)=='0')
				idx1=i;
	}
	if(idx1==-1 || idx2==-1)
		return 100;
	int ans=0;
	if(idx1==0 || idx2==0)
		for(int i=1;i<num.length()&&num.charAt(i)=='0'&&!s.equals("50");i++,ans++);
	
	if(idx1>idx2)
	{
		ans+=idx1-idx2;
		idx2=idx1;
		idx1--;
	}
	
	int len=num.length();
	ans+=len-2-idx1+len-1-idx2;
	
	return ans;
	
}
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		String s=sc.next();
		int n=s.length();
		if(s.length()<2)
		{
			System.out.println(-1);
			return;
		}
		
		int ans=100;
		
		
		int x=solve("25",s);
		ans=Math.min(ans, x);
		//System.out.println(x);
		x=solve("75",s);
		ans=Math.min(ans, x);
		//System.out.println(x);
		 x=solve("50",s);
		 ans=Math.min(ans, x);
		
		 x=solve("00",s);
		 ans=Math.min(ans, x);
		 
		System.out.println(ans==100?-1:ans);
			
		
	}
	

	static class pair implements Comparable<pair>
	{
		String s;
		
		pair(char []x)
		{
			
			s=new String(x);
		}
		@Override
		public int compareTo(pair p) {
			// TODO Auto-generated method stub
			return s.length()-p.s.length();
		}
		
	}
	
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		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 boolean ready() throws IOException {
			return br.ready();
		}
	}
}