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;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long int n;
  cin >> n;
  vector<long long int> dig;
  long long int m = n;
  while (m > 0) {
    dig.push_back(m % 10);
    m /= 10;
  }
  long long int t_0 = -1, t_5 = -1;
  for (long long int i = 0; i < (long long int)dig.size(); i++) {
    if (dig[i] == 0) {
      t_0 = i;
      long long int first = 0;
      for (long long int j = 0; j < (long long int)dig.size(); j++) {
        if (j == i) continue;
        if (dig[j] == 0 || dig[j] == 5) {
          if (j > i)
            t_0 += j - 1;
          else
            t_0 += j;
          first = 1;
          break;
        }
      }
      if (!first) t_0 = -1;
      break;
    }
  }
  vector<long long int> idx;
  for (long long int i = 0; i < dig.size(); i++) {
    if (dig[i] == 5) {
      t_5 = i;
      idx.push_back(i);
      long long int first = 0;
      for (long long int j = 0; j < dig.size(); j++) {
        if (j == i) continue;
        if (dig[j] == 2 || dig[j] == 7) {
          if (j > i)
            t_5 += j - 1;
          else
            t_5 += j;
          idx.push_back(j);
          first = 1;
          break;
        }
      }
      if (!first) t_5 = -1;
      break;
    }
  }
  if (t_5 != -1) {
    long long int first = 0;
    vector<long long int> x;
    for (long long int i = 0; i < dig.size(); i++) {
      if (i != idx[0] && i != idx[1]) x.push_back(dig[i]);
    }
    for (long long int i = (long long int)x.size() - 1; i >= 0; i--) {
      if (x[i] != 0) {
        t_5 += (x.size() - 1 - i);
        first = 1;
        break;
      }
    }
    if (!first && x.size() > 0) t_5 = -1;
  }
  vector<long long int> ans;
  if (t_0 != -1) ans.push_back(t_0);
  if (t_5 != -1) ans.push_back(t_5);
  if (!ans.size())
    cout << "-1";
  else
    cout << *min_element(ans.begin(), ans.end());
  return 0;
}