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;
ifstream in;
ofstream out;
const long long INF = LLONG_MAX;
const long double EPS = 1e-9;
const long double pi = 3.141592653589793238462643383279502884;
string s;
long long n;
vector<long long> a(10);
long long answer = 0;
vector<pair<bool, long long>> ans(4, {0, 0});
void sw(long long a, long long b, string &t);
pair<bool, long long> solve(long long x, long long y) {
  answer = 0;
  if (x == y)
    if (a[0] >= 2) {
    } else
      return {0, -1};
  else if (a[x] >= 1 && a[y] >= 1) {
  } else
    return {0, -1};
  string t = s;
  long long t1 = 0, t2 = 1;
  for (; t1 < n; t1++)
    if (t[t1] - '0' == y) break;
  if (t1 != 0) sw(t1, 0, t);
  for (; t2 < n; t2++)
    if (t[t2] - '0' == x) break;
  if (t2 != 1) sw(t2, 1, t);
  if (x == y && a[0] == n) return {0, -1};
  if (a[0] == n - 2 + (y == 0) + (x == 0) && n != 2) return {0, -1};
  reverse((t).begin(), (t).end());
  long long i = 0;
  for (; i < n; i++)
    if (t[i] != '0') break;
  return {1, answer + i};
  answer = 0;
}
void sw(long long a, long long b, string &t) {
  for (long long i = a - 1; i >= b; i--) {
    swap(t[i], t[i + 1]);
    answer++;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  srand(time(0));
  cin >> s;
  n = s.size();
  if (n == 1) {
    cout << -1 << endl;
    return 0;
  }
  reverse((s).begin(), (s).end());
  for (char i : s) a[i - '0']++;
  ans[0] = solve(0, 0);
  ans[1] = solve(2, 5);
  ans[2] = solve(5, 0);
  ans[3] = solve(7, 5);
  long long answer = INF;
  for (long long i = 0; i < 4; i++)
    if (ans[i].first) answer = min(answer, ans[i].second);
  if (ans[0].first || ans[1].first || ans[2].first || ans[3].first)
    cout << answer << endl;
  else
    cout << -1 << endl;
  return 0;
}