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.util.Scanner;

public class DivisibilityBy25 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		System.out.println(getDivisibleBy25(num));
	}
	
	public static String getDivisibleBy25(String num) {
		StringBuilder sb = new StringBuilder();
        
        for(int i = num.length() - 1; i >= 0; i--)
        {
            sb.append(num.charAt(i));
        }
        num = sb.toString();
		char n[] = num.toCharArray();
		int l = n.length;

		int twoInd = -1;
		int sevenInd = -1;
		int fiveInd = -1;
		int zeroInd = -1;
		int zero2Ind = -1;
		int countZeros = 0;
		int lastZeroInd = -1;
		for(int i=0;i<l;i++) {
			if(n[i]=='2' && twoInd==-1) {
				twoInd = i;
			} else if(n[i]=='5' && fiveInd==-1) {
				fiveInd = i;
			} else if(n[i]=='7' && sevenInd==-1) {
				sevenInd = i;
			} else if(n[i]=='0' && zero2Ind==-1) {
				if(zeroInd==-1) {
					zeroInd = i;
				} else {
					zero2Ind = i;
				}
			}
			if(n[i]=='0') {
				lastZeroInd = i;
				if(i>0 && n[i-1]=='0')
					countZeros++;
				else 
					countZeros=1;
			}
		}
		
		int twoFive = -1;
		int fiveZero = -1;
		int sevenFive = -1;
		int zeroZ = -1;
		int min = -1;
		if(twoInd >-1 && fiveInd>-1) {
			twoFive = twoInd + fiveInd -1 ;	
			if(twoInd<fiveInd) {
				twoFive++;
			}
			if((fiveInd==l-1 || twoInd==l-1) && (lastZeroInd==l-2)) {
				//twoFive++;
				if(lastZeroInd==l-2) {
					twoFive+=countZeros;
				}
				/*if(zero2Ind!=-1 && zero2Ind-zeroInd==1)
					twoFive++;*/
			}
			min = twoFive;
		}
		if(sevenInd >-1 && fiveInd>-1) {
			sevenFive = sevenInd + fiveInd -1 ;	
			if(sevenInd<fiveInd) {
				sevenFive++;
			}
			if((fiveInd==l-1 || sevenInd==l-1) && (lastZeroInd==l-2)) {
				//sevenFive++;
				if(lastZeroInd==l-2) {
					sevenFive+=countZeros;
				}
				/*if(zero2Ind!=-1 && zero2Ind-zeroInd==1)
					sevenFive++;*/
			}
			if(min==-1 || min>sevenFive)
				min = sevenFive;

		}
		if(zeroInd >-1 && fiveInd>-1) {
			fiveZero = zeroInd + fiveInd -1 ;	
			if(fiveInd<zeroInd) {
				fiveZero++;
			}
			if((fiveInd==l-1) && (lastZeroInd==l-2)) {
				//fiveZero++;
				if(lastZeroInd==l-2) {
					fiveZero+=countZeros-1;
				}
				/*if(zero2Ind!=-1 && zero2Ind-zeroInd==1)
					fiveZero++;*/
			}
			if(min==-1 || min>fiveZero)
				min = fiveZero;
		}
		if(zeroInd >-1 && zero2Ind>-1) {
			zeroZ = zeroInd + zero2Ind -1 ;	
			if(min==-1 || min>zeroZ)
				min = zeroZ;
		}
		
		return ""+min;
	
	}

}