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 Main implements Runnable {

    int maxn = (int)1e5+111;
    int n,m,k;

    void solve() throws Exception {
        char c[] = in.nextToken().toCharArray();
        n = c.length;
        ArrayList<Integer> original = new ArrayList<>();
        for (int i=0; i<c.length; i++) {
            original.add(c[i]-'0');
        }

        int df[] = {0,2,5,7};
        int ds[] = {0,5,0,5};

        int min = Integer.MAX_VALUE;
        for (int i=0; i<df.length; i++) {
            int first = -1;
            int second = -1;
            ArrayList<Integer> list = (ArrayList<Integer>) original.clone();
            if (i==0) {
                for (int j=list.size()-1; j>=0; j--) {
                    int cur = list.get(j);
                    if (second==-1 && cur==df[i]) {
                        second = j;
                    } else if (first==-1 && cur==ds[i]) {
                        first = j;
                        break;
                    }
                }
            } else {
                for (int j = 0; j < list.size(); j++) {
                    int cur = list.get(j);
                    if (cur == df[i]) {
                        first = j;
                    }
                    if (cur == ds[i]) {
                        second = j;
                    }
                }
            }

            if (first!=-1 && second!=-1) {
                int ans = 0;
//                out.println("i : " + first + " " + second);
                if (first>second) {
                    list.remove(first);
                    list.add(df[i]);
                    list.remove(second);
                    list.add(ds[i]);
                    ans += Math.abs(n-1-first);
                    ans += Math.abs(n-1-second);
                } else {
                    list.remove(second);
                    list.add(ds[i]);
                    list.remove(first);
                    list.add(df[i]);
                    ans += Math.abs(n-1-second);
                    ans += Math.abs(n-2-first);
                }

                if (list.get(0)==0) {
                    for (int j=0; j<n-2; j++) {
                        if (list.get(j)!=0) {
                            ans += j;
                            break;
                        }
                    }
                }
                min = Math.min(min, ans);
            }
        }

        if (min==Integer.MAX_VALUE) {
            out.println(-1);
            return;
        }
        out.println(min);

    }

    class Pair implements Comparable<Pair> {
        long x;
        long y;
        int ind;
        int ans;

        public Pair(long x, long y, int ind) {
            this.x = x;
            this.y = y;
            this.ind = ind;
        }

        @Override
        public int compareTo(Pair p) {
            long left = Math.abs(this.x - this.y);
            long right = Math.abs(p.x - p.y);
            if (left<right) return 1;
            else if (left==right) return 0;
            else return -1;
        }

        @Override
        public String toString() {
            return "Pair{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }

    String fileInName = "";

    boolean file = false;
    boolean isAcmp = false;

    static Throwable throwable;
    public static void main (String [] args) throws Throwable {
        Thread thread = new Thread(null, new Main(), "", (1 << 26));
        thread.start();
        thread.join();
        thread.run();
        if (throwable != null)
            throw throwable;
    }

    FastReader in;
    PrintWriter out;

    public void run() {
        String fileIn = "absum.in";
        String fileOut = "absum.out";

        try {
            if (isAcmp) {
                if (file) {
                    in = new FastReader(new BufferedReader(new FileReader(fileIn)));
                    out = new PrintWriter (fileOut);
                } else {
                    in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
                    out = new PrintWriter(System.out);
                }
            } else if (file) {
                in = new FastReader(new BufferedReader(new FileReader(fileInName+".in")));
                out = new PrintWriter (fileInName + ".out");
            } else {
                in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(System.out);
            }

            solve();
        } catch(Exception e) {
            throwable = e;
        } finally {
            out.close();
        }

    }


}

class FastReader {
    BufferedReader bf;
    StringTokenizer tk = null;

    public FastReader(BufferedReader bf) {
        this.bf = bf;
    }

    public String nextToken () throws Exception {
        if (tk==null || !tk.hasMoreTokens()) {
            tk = new StringTokenizer(bf.readLine());
        }
        if (!tk.hasMoreTokens()) return nextToken();
        else
            return tk.nextToken();
    }

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}