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:
// package CodeForces;

import java.io.*;
import java.util.*;

public class Problem_988E {
	static boolean valid(char[]tmp)
	{
		int n=tmp.length;
		if(tmp[n-2]=='2' && tmp[n-1]=='5')
			return true;
		if(tmp[n-2]=='5' && tmp[n-1]=='0')
			return true;
		if(tmp[n-2]=='7' && tmp[n-1]=='5')
			return true;
		if(tmp[n-2]=='0' && tmp[n-1]=='0')
			return true;
		return false;
	}
	static int move(int i,int j)
	{
		char []tmp=c.clone();
		int moves=0;
		if(i>j)
			i--;
		while(j<tmp.length-1)
		{
			char cc=tmp[j];
			tmp[j]=tmp[j+1];
			tmp[j+1]=cc;
			moves++;
			j++;
		}
		while(i<tmp.length-2)
		{
			char cc=tmp[i];
			tmp[i]=tmp[i+1];
			tmp[i+1]=cc;
			moves++;
			i++;
		}
		int z;
		for(z=0;z<tmp.length;z++)
			if(tmp[z]!='0')
			{
				char cc=tmp[z];
				tmp[z]=tmp[0];
				tmp[0]=cc;
				moves+=z;
				break;
			}
		if(valid(tmp))
			return moves;
		return -1;
	}
	static int solve(int x,int y)
	{
		int ans=(int)1e9;
		for(int i:lastindx[x])
		{
			for(int j:lastindx[y])
			{
				if(i==j)
					continue;
				int move=move(i,j);
				if(move!=-1)
					ans=Math.min(ans, move);
			}
		}
		return ans;
	}
	static char c[];
	static ArrayList<Integer> lastindx[];
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		c=sc.nextLine().toCharArray();
		lastindx=new ArrayList[10];
		for(int i=0;i<10;i++)
			lastindx[i]=new ArrayList<>();
		for(int i=0;i<c.length;i++)
			lastindx[c[i]-'0'].add(i);
		int ans=(int)1e9;
		ans=Math.min(ans, solve(2,5));
		ans=Math.min(ans, solve(5,0));
		ans=Math.min(ans, solve(7,5));
		ans=Math.min(ans, solve(0,0));
		pw.print(ans==(int)1e9?-1:ans);
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() throws IOException {
			return br.readLine();
		}

		boolean hasnext() throws IOException {
			return br.ready();
		}

	}
}