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;
char d;
int m = INT_MAX;
int t = 0;
int bit = 1;
int bay = 0, st = -1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int l = s.length();
  vector<int> s0, s2, s5;
  for (int i = l - 1; i >= 0; --i) {
    if (s[i] == '0')
      s0.push_back(l - 1 - i);
    else if (s[i] == '2')
      s2.push_back(l - 1 - i);
    else if (s[i] == '5')
      s5.push_back(l - i - 1);
    else if (s[i] == '7') {
      s[i] = '2';
      s2.push_back(l - 1 - i);
    }
  }
  if (s0.size() > 1) {
    t = 0;
    t += s0[0] + s0[1] - 1;
    if (s5.size() != 0) {
      if (s5[0] > s0[1]) bit = 0;
    }
    if (t < m) m = t;
  } else if (s0.size() != 0 && s5.size() != 0 && bit == 1) {
    t = 0;
    if (s0[0] > s5[0])
      t += s0[0] + s5[0];
    else
      t += s0[0] + s5[0] - 1;
    if (t < m) m = t;
  }
  if (s0.size() == 0 && s5.size() != 0 && s2.size() != 0) {
    t = 0;
    if (s5[0] > s2[0])
      t += s2[0] + s5[0];
    else
      t += s2[0] + s5[0] - 1;
    if (t < m) m = t;
  } else if (s0.size() != 0 && s5.size() != 0 && s2.size() != 0) {
    if (s0[0] > s2[0] && s0[0] < s5[0]) {
      string ss = s;
      t = 0;
      int k2 = l - 1 - s2[0];
      int k5 = l - 1 - s5[0];
      for (int i = k2; i < l - 1; ++i) {
        d = s[i];
        s[i] = s[i + 1];
        s[i + 1] = d;
        t++;
      }
      for (int i = k5; i < l - 1; ++i) {
        d = s[i];
        s[i] = s[i + 1];
        s[i + 1] = d;
        t++;
      }
      for (int i = 0; i < l - 2; ++i) {
        if (s[i] != '0') {
          bay = 1;
          st = i;
          break;
        }
      }
      if (bay == 0)
        t = INT_MAX;
      else
        t = t + st;
      if (t < m) m = t;
      s = ss;
    } else {
      t = 0;
      if (s5[0] > s2[0])
        t += s2[0] + s5[0];
      else
        t += s2[0] + s5[0] - 1;
      if (t < m) m = t;
    }
  }
  if (m == INT_MAX)
    cout << "-1\n";
  else
    cout << m << endl;
}