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;
const int inf = 0x3f3f3f3f;
string n;
int len;
int solve_00() {
  int pos[20], cnt = 0;
  for (int i = 0; i < len; i++)
    if (n[i] == '0') pos[++cnt] = i;
  if (cnt < 2) return inf;
  return len - 1 - pos[cnt] + len - 2 - pos[cnt - 1];
}
int solve_other(int l1, int l2) {
  int pos1 = -1, pos2 = -1, ret = 0;
  string tn = n;
  for (int i = 0; i < len; i++) {
    if (tn[i] - '0' == l1) pos1 = i;
    if (tn[i] - '0' == l2) pos2 = i;
  }
  if (pos1 == -1 || pos2 == -1) return inf;
  int lpos = min(pos1, pos2), rpos = max(pos1, pos2);
  for (int i = rpos; i < len - 1; i++, ret++) swap(tn[i], tn[i + 1]);
  if (lpos == 0)
    for (int i = 1; tn[i] == '0' && i < len - 1; i++, ret++)
      if (i == len - 2) return inf;
  ret += len - 2 - lpos + (lpos == pos2);
  return ret;
}
int main() {
  cin >> n;
  len = n.size();
  int ans = solve_00();
  ans = min(ans, solve_other(2, 5));
  ans = min(ans, solve_other(5, 0));
  ans = min(ans, solve_other(7, 5));
  if (ans == inf) ans = -1;
  cout << ans;
  return 0;
}