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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void dbg(T a) {}
template <typename T, typename... Arg>
void dbg(T a, Arg... arg) {}
const int maxn = (1e6) + 7;
const int inf = (1e9) + 7;
const long long LLinf = (1e18) + 7;
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
int ile(vector<int> V) {
  int res = 0;
  while (((int)(V).size()) && V.back() == 0) {
    V.pop_back();
    res++;
  }
  if (((int)(V).size()) == 0) return 10000;
  return res;
}
int rob(vector<int> V, int a, int b) {
  int cnt = 0;
  for (int i = 0; i < ((int)(V).size()); i++)
    if (V[i] == a) {
      for (int j = i - 1; j >= 0; j--) {
        swap(V[j], V[j + 1]);
        cnt++;
      }
      break;
    }
  for (int i = 1; i < ((int)(V).size()); i++)
    if (V[i] == b) {
      for (int j = i - 1; j > 0; j--) {
        swap(V[j], V[j + 1]);
        cnt++;
      }
      break;
    }
  if (V[0] == a && V[1] == b)
    return cnt + ile(V);
  else
    return 1000;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<int> V;
  while (n > 0) {
    V.push_back(n % 10);
    n /= 10LL;
  }
  int res = 1000;
  res = min(res, rob(V, 0, 0));
  res = min(res, rob(V, 5, 2));
  res = min(res, rob(V, 0, 5));
  res = min(res, rob(V, 5, 7));
  if (res < 100)
    cout << res;
  else
    cout << "-1";
  return 0;
}