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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Atharva Nagarkar
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        JoltyScanner in = new JoltyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        int move(int[] s, int x, int y) {
            int n = s.length;
            int ans = 0;
            for (int i = n - 1; i >= 0; --i) {
                if (s[i] == y) {
                    for (int j = i; j < n - 1; ++j) {
                        int temp = s[j];
                        s[j] = s[j + 1];
                        s[j + 1] = temp;
                        ++ans;
                    }
                    break;
                }
            }
            for (int i = n - 2; i >= 0; --i) {
                if (s[i] == x) {
                    for (int j = i; j < n - 2; ++j) {
                        int temp = s[j];
                        s[j] = s[j + 1];
                        s[j + 1] = temp;
                        ++ans;
                    }
                    break;
                }
            }
            if (s[0] == 0) {
                boolean found = false;
                for (int i = 0; i < n - 2; ++i) {
                    if (s[i] == 0) ++ans;
                    else {
                        found = true;
                        break;
                    }
                }
                if (!found) return 987654321;
            }
            return ans;
        }

        public void solve(int testNumber, JoltyScanner in, PrintWriter out) {
            String s = in.next();
            int[] count = new int[10];
            for (char c : s.toCharArray()) count[c - '0']++;
            boolean hun = (count[0] >= 2);
            boolean tf = (count[2] >= 1 && count[5] >= 1);
            boolean fi = (count[5] >= 1 && count[0] >= 1);
            boolean sf = (count[7] >= 1 && count[5] >= 1);
            boolean possible = hun || tf || fi || sf;
            if (!possible) {
                out.println(-1);
                return;
            }
            int[] a = new int[s.length()];
            for (int i = 0; i < s.length(); ++i) a[i] = s.charAt(i) - '0';
            int ans = 987654321;
            if (hun) ans = Math.min(ans, move(a.clone(), 0, 0));
            if (tf) ans = Math.min(ans, move(a.clone(), 2, 5));
            if (fi) ans = Math.min(ans, move(a.clone(), 5, 0));
            if (sf) ans = Math.min(ans, move(a.clone(), 7, 5));
            out.println(ans);
        }

    }

    static class JoltyScanner {
        public int BS = 1 << 16;
        public char NC = (char) 0;
        public byte[] buf = new byte[BS];
        public int bId = 0;
        public int size = 0;
        public char c = NC;
        public BufferedInputStream in;

        public JoltyScanner(InputStream is) {
            in = new BufferedInputStream(is, BS);
        }

        public JoltyScanner(String s) throws FileNotFoundException {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        }

        public char nextChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = nextChar();
            while (c > 32) {
                res.append(c);
                c = nextChar();
            }
            return res.toString();
        }

    }
}