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.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        char[] s = sb.append(sc.next()).reverse().toString().toCharArray();
        int[] digits = new int[10];
        for(char c : s){
            digits[c-'0']++;
        }
        int ans = 100;
        char[] tmp = s.clone();
        if(digits[2] >= 1 && digits[5] >= 1){
            ans = Math.min(ans,countSwap('5','2',tmp));
        }
        //pw.println(ans);
        if(digits[5] >= 1 && digits[0] >= 1){
            tmp = s.clone();
            ans = Math.min(ans,countSwap('0','5',tmp));
        }
        //pw.println(ans);
        if(digits[7] >= 1 && digits[5] >= 1){
            tmp = s.clone();
            ans = Math.min(ans,countSwap('5','7',tmp));
        }
        //pw.println(ans);
        if(digits[0] >= 2){
            tmp = s.clone();
            ans = Math.min(ans,countSwap('0','0',tmp));
        }
        pw.println(ans == 100 ? -1 : ans);
        pw.flush();
    }
    
    static int countSwap(char c1, char c2, char[] s){
        int ret = 0;
        int s1 = 0;
        int len = s.length;
        for(int i = 0; i < len; i++){
            if(s[i] == c1){
                s1 = i;
                break;
            }
        }
        for(int i = s1-1; i >= 0; i--){
            char t = s[i];
            s[i] = s[i+1];
            s[i+1] = t;
            ret++;
        }
        int s2 = 0;
        for(int i = 1; i < len; i++){
            if(s[i] == c2){
                s2 = i;
                break;
            }
        }
        for(int i = s2-1; i >= 1; i--){
            char t = s[i];
            s[i] = s[i+1];
            s[i+1] = t;
            ret++;
        }
        //System.out.println(new String(s) + " " + ret + " " + len);
        boolean flg = false;
        if(len <= 2){
            return ret;
        }
        for(int i = len-1; i >= 2; i--){
            //System.out.println(s[i]);
            if(s[i] != '0'){
                flg = true;
                break;
            }
            ret++;
        }
        return flg ? ret : 100; 
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}