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.*;
import java.io.*;

// Solution

public class Main 
{    
  public static void main (String[] argv) 
  {
	  new Main();
  } 
     
  
  boolean test = false;
  
  
  public Main() {
	  FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
	  //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in")));
      char[] a = in.next().toCharArray();
      int n = a.length;
      if (n == 1) {
          System.out.println(-1);
          return;
      }
      if (done(a[n-2], a[n-1])) {
          System.out.println(0);
          return;
      }
      
      int ans = move(a, '0', '0');
      ans = min(ans, move(a, '2','5'));
      ans = min(ans, move(a, '7','5'));
      ans = min(ans, move(a, '5','0'));
      if (ans == Integer.MAX_VALUE) System.out.println(-1);
      else System.out.println(ans);
  }
  
  private int move(char[] a, char x, char y) {
      int hi = a.length - 1;
      int ix = -1, iy = -1;
      for (int i = hi; i >= 0; i--) {
          if(a[i] == y) {
              iy = i;
              break;
          }
      }
      
      for (int i = hi; i >= 0; i--) {
          if(i != iy && a[i] == x) {
              ix = i;
              break;
          }
      }
      
      if (ix == -1 || iy == -1) return Integer.MAX_VALUE;
      
      if (hi == 1) {
          return 1;
      }
      
      int c = -1;
      for (int i = 0; i <= hi; i++) {
          if (i != ix && i != iy && a[i] != '0') {
              c = i;
              break;
          }
      }
      if (c == -1) return Integer.MAX_VALUE;
      
      if (ix < iy) {
          if (c < ix) {
              return hi - iy + hi - 1 - ix;
          }else if (c < iy) {
              return hi - iy + c - 1 + hi - 1 - ix;
          }else {
              return hi - iy + c + hi - 3 - ix;
          }
      }else {
          if (c < iy) {
              return hi - iy + hi - ix;
          }else if (c < ix) {
              return hi - iy + c - 1 + hi - ix;
          }else {
              return hi - iy + c + hi - 2 - ix;
          }
      }
  }
  
  private boolean done(char x, char y) {
      return (x == '0' && y == '0') || (x == '5' && y == '0') || (x == '2' && y == '5')
       || (x == '7' && y == '5');
  }
  
  private boolean match(char l, char r) {
      return (l == '(' && r == ')')  || (l == '[' && r == ']');
  }
  private int max(int a, int b) {
      return a >  b ? a : b;
  }
  
  private int min(int a, int b) {
      return a >  b ? b : a;
  }
  
  
  static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader(BufferedReader in)
        {            
            br = in;
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    String line = br.readLine();
                    if (line == null || line.length() == 0) return "";
                    st = new StringTokenizer(line);
                }
                catch (IOException  e)
                {
                    return "";
                    //e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                return "";
                //e.printStackTrace();
            }
            return str;
        }
    }
}