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 double PI = acos(-1.0);
typedef tuple<int, int> i2;
typedef tuple<int, int, int> i3;
typedef tuple<int, int, int, int> i4;
typedef vector<int> vi;
typedef vector<i2> vi2;
typedef vector<i3> vi3;
typedef vector<i4> vi4;
typedef vector<vi> v2i;
typedef vector<vi2> v2i2;
typedef vector<string> vs;
long long modPow(long long b, long long p, long long m) {
  if (p <= 1) return p == 0 ? 1 : b;
  long long res = ((modPow(b, p / 2, m) * modPow(b, p / 2, m)) % m);
  if (p % 2 != 0) res *= ((b) % m);
  return ((res) % m);
}
typedef tuple<int, double> id;
int t;
int solve(int a, int b, string s) {
  char x = '0' + a, y = '0' + b;
  int res = 0, i;
  for (i = 0; i < ((int)s.size()); ++i) {
    if (s[i] == y) {
      s = y + s.substr(0, i) + s.substr(i + 1);
      break;
    }
  }
  if (i == ((int)s.size())) return -1;
  res += i;
  for (i = 1; i < ((int)s.size()); ++i)
    if (s[i] == x) {
      s = string(1, s[0]) + string(1, x) + s.substr(1, i - 1) + s.substr(i + 1);
      break;
    }
  if (i == ((int)s.size())) return -1;
  res += i - 1;
  for (i = ((int)s.size()) - 1; i >= 2; --i) {
    if (s[i] != '0') break;
  }
  res += ((int)s.size()) - i - 1;
  return i > 1 || ((int)s.size()) < 3 ? res : -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.setf(ios::fixed);
  cout.precision(1);
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  if (s == "0")
    cout << 0 << '\n';
  else {
    int res = -1, k;
    k = solve(0, 0, s);
    if (k != -1) res = res == -1 ? k : min(res, k);
    k = solve(2, 5, s);
    if (k != -1) res = res == -1 ? k : min(res, k);
    k = solve(5, 0, s);
    if (k != -1) res = res == -1 ? k : min(res, k);
    k = solve(7, 5, s);
    if (k != -1) res = res == -1 ? k : min(res, k);
    cout << res << '\n';
  }
  return 0;
}