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.*;
import java.util.*;
public class Divisibility_25 { //500111117

	public static void main(String[] args) throws NumberFormatException, IOException {
		  BufferedReader jh = new BufferedReader(new InputStreamReader(System.in)) ; 
		  long n = Long.parseLong(jh.readLine()) ;
          Vector<Long> v = new Vector<Long>() ; 
          long p= n ; 
          while(p>0)
          {
        	  v.add(p%10) ;  p=p/10 ; 
          }
          Vector<Long>  elu = new Vector<Long>() ; 
          boolean temoin0=false ; boolean temoin2=false ; boolean temoin5=false ; boolean temoin7 =false ; 
          int j=0 ; 
          int compt0=0 ; 
          int swap0 =50 ; int swap2=50 ; int swap5 =50 ; int swap7=50 ; int swap00=50 ; 
          boolean entre =false ; 
          while(  (  (!temoin0 | !temoin5) | (!temoin2 | !temoin5)  | (!temoin7 | !temoin5) |(compt0<=1)  ) & j<v.size())
          {
        	 if(v.elementAt(j)==0 & compt0<=1)
        	 {
        		 compt0++ ;
        		 if(compt0==1)
        		 {
        			 swap0=j ;  temoin0=true ; 
        		 }
        		 else if(compt0==2) 
        			 {
        			   swap00=j ; 
        			 }
        	 }
        	 else if(v.elementAt(j)==2 & !temoin2)
        	 {
        		 temoin2=true; swap2=j ;
        	 }
        	 else if(v.elementAt(j)==5 & !temoin5)
        	 {
        		 temoin5=true; swap5=j ;
        	 }
        	 else if(v.elementAt(j)==7 & !temoin7)
        	 {
        		 temoin7=true; swap7=j ;
        	 }
        	 j++ ;
          }
         
          if((temoin0 & temoin5) | (temoin2 & temoin5) | (temoin7 & temoin5) |(compt0==2) )
        	  {
        	   
        	  if(swap5>swap0) elu.add((long) (swap0+swap5-1));
        	  else elu.add((long) (swap0+swap5));
          
        	  if(swap5==v.size()-1)
        	  {   
        		  int io=v.size()-2 ; 
        			  while( io>0 & v.elementAt(io)==0)
        			  {
            			  swap5++ ; io-- ; 
            		  }
        		  
        	  }
        	  
        	  if(swap2==v.size()-1)
        	  {
        		  int io=v.size()-2 ; 
        		  
        			  while(v.elementAt(io)==0 & io>=0){
            			  swap2++ ; io-- ; 
            		  }
        		  
        	  }
    	      if(swap2>swap5) elu.add((long) (swap5+swap2-1));
    	      else elu.add((long) (swap2+swap5));
    	     
          
           
    	      if(swap7==v.size()-1)
        	  {  
        		  int io=v.size()-2 ; 
        		  
        			  while(v.elementAt(io)==0 && io>=0){
            			  swap7++ ; io-- ; 
            		  }
        		  
        	  }
    	       if(swap7>swap5) elu.add((long) (swap7+swap5-1));
    	       else elu.add((long) (swap7+swap5));
    	      
          
         
    	       elu.add((long) (swap0+swap00-1)) ;
        	  }
          else {
        	  System.out.println(-1); entre=true ; 
          }
          
          if(!entre)   
          {
        	  Collections.sort(elu);
        	  System.out.println(elu.elementAt(0));
          }
          
          
          
	}

}