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.math.*;
import java.sql.Timestamp;
import java.text.*;
import java.time.LocalDateTime;
import java.util.*;

public class Watermelon {
    static int count=0,ans=0;
    static int n,m,k,s;
    static HashMap<Integer,ArrayList<Integer>> map=new HashMap<>();
    static int[][] goods;
    static int[][] dist;
    static int[][] adj;

    public static void main(String[] args) throws IOException, ParseException {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int mcount=Integer.MAX_VALUE;
        for(int i=0;i<s.length();i++){
            for(int j=0;j<s.length();j++){
                if(i==j)continue;
                char[] t=s.toCharArray();
                if(!((t[j]=='5'&&t[i]=='0')||(t[j]=='2'&&t[i]=='5')||(t[j]=='7'&&t[i]=='5')||(t[j]=='0'&&t[i]=='0')) )continue;
                int count=0;
                for(int k=i;k<t.length-1;k++){
                    char temp=t[k];
                    t[k]=t[k+1];
                    t[k+1]=temp;
                    count++;
                }
                for(int k=j-((j>i)?1:0);k<t.length-2;k++){
                    char temp=t[k];
                    t[k]=t[k+1];
                    t[k+1]=temp;
                    count++;
                }
                int k=0;
                while(t[k]=='0'){
                    count++;
                    k++;
                }
                mcount=Math.min(mcount,count);
            }
        }
        System.out.println((mcount==Integer.MAX_VALUE)?-1:mcount);
    }
    static class Reader{
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }

            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }
}