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 Test
{
    static PrintWriter pw = new PrintWriter(System.out);
    static int n;
    static ArrayList<Integer>[] ind = new ArrayList[10];

    static int get(char[] t , int x , int y)
    {
        if(ind[x].size() == 0 || ind[y].size() == 0) return  -1;

        int res = 0;
        int b = ind[y].get(ind[y].size()-1);

        if(x == y && ind[x].size() < 2)return -1;

        for(int i = b ; i<n-1 ; i++)
        {
            res++;
            char ch = t[i];
            t[i] = t[i+1];
            t[i+1] = ch;
        }

        int a = 0;
        for(int i = 0 ; i<n-1 ; i++)if(t[i]-'0' == x)a = i;


        for(int i = a ; i<n-2 ; i++)
        {
            res++;
            char ch = t[i];
            t[i] = t[i+1];
            t[i+1] = ch;

        }

        int z = 0;
        for(int i = 0 ; i<n-2 ; i++)
            if(t[i] != '0')
            {
                z = i;
                break;
            }


        if(t[0] == '0' && n == 3)return -1;

        return z + res;

    }

    public static void main(String[] args)throws Exception
    {
        Reader.init(System.in);

        char[] a = Reader.next().toCharArray();
        n = a.length;

        for(int i = 0 ; i<10 ; i++)ind[i] = new ArrayList();

        for(int i = 0 ; i<n ; i++)ind[a[i] - '0'].add(i);

        int[] x = {0 , 2 , 5 , 7};
        int[] y = {0 , 5 , 0 , 5};

        int res = Integer.MAX_VALUE;

        for(int i = 0 ; i<4 ; i++)
        {
            char[] t = new char[n];
            for(int j = 0 ; j<n ; j++)t[j] = a[j];

            int z = get(t , x[i] , y[i]);
            if(z != -1) res = Math.min(res , z);
        }


        if(res == Integer.MAX_VALUE)pw.print(-1);
        else pw.print(res);

        pw.close();
    }


}



class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return pars(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}