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;
int main() {
  string a;
  cin >> a;
  int s1 = -1, s2 = -1;
  bool t;
  for (int i = a.size() - 1; i >= 0; --i)
    if (a[i] == '0') {
      string b = a;
      s1 = -1;
      t = false;
      for (int j = i; j < a.size() - 1; ++j, ++s1) swap(b[j], b[j + 1]);
      for (int j = a.size() - 2; j >= 0; --j)
        if (b[j] == '0' || b[j] == '5') {
          t = true;
          for (int k = j; k < a.size() - 2; ++k, ++s1) swap(b[k], b[k + 1]);
          break;
        }
      if (t)
        if (b[0] == '0') {
          for (int j = 0; j < b.size() - 2; ++j)
            if (b[j] != '0') {
              for (int k = j; k > 0; --k, ++s1) swap(b[k], b[k - 1]);
              break;
            }
          ++s1;
          break;
        } else {
          ++s1;
          break;
        }
      else
        s1 = -1;
    }
  for (int i = a.size() - 1; i >= 0; --i)
    if (a[i] == '5') {
      string b = a;
      s2 = -1;
      t = false;
      for (int j = i; j < a.size() - 1; ++j, ++s2) swap(b[j], b[j + 1]);
      for (int j = a.size() - 2; j >= 0; --j)
        if (b[j] == '2' || b[j] == '7') {
          t = true;
          for (int k = j; k < a.size() - 2; ++k, ++s2) swap(b[k], b[k + 1]);
          break;
        }
      if (t)
        if (b[0] == '0') {
          for (int j = 0; j < b.size() - 2; ++j)
            if (b[j] != '0') {
              for (int k = j; k > 0; --k, ++s2) swap(b[k], b[k - 1]);
              break;
            }
          ++s2;
          break;
        } else {
          ++s2;
          break;
        }
      else
        s2 = -1;
    }
  if (a == "0")
    cout << 0 << endl;
  else if (s1 == -1)
    if (s2 == -1)
      cout << -1 << endl;
    else
      cout << s2 << endl;
  else if (s2 == -1)
    cout << s1 << endl;
  else
    cout << min(s1, s2) << endl;
  return 0;
}