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 s;
  vector<long long> v;
  long long a_2, a_5, b_0, b_5, c_7, c_5, d_0, d_01, i, k, len;
  cin >> s;
  reverse(s.begin(), s.end());
  len = s.length();
  long long maxx = 1e7;
  long long min_25 = maxx, min_50 = maxx, min_75 = maxx, min_00 = maxx;
  a_2 = s.find("2");
  a_5 = s.find("5");
  b_5 = s.find("5");
  b_0 = s.find("0");
  c_7 = s.find("7");
  c_5 = s.find("5");
  d_0 = s.find("0");
  if (d_0 != -1) {
    d_01 = s.substr(d_0 + 1, s.length()).find("0");
    if (d_01 != -1) {
      d_01 = d_01 + d_0 + 1;
    }
  } else
    d_01 = -1;
  if (a_2 != -1 && a_5 != -1) {
    if (a_5 < a_2)
      min_25 = a_5 + (a_2 - 1);
    else
      min_25 = a_5 + a_2;
    if (a_5 == (len - 1) && s[len - 2] == '0') {
      k = 0;
      for (i = len - 2; i >= 0; i--) {
        if (s[i] != '0') break;
        k++;
      }
      if (i == a_2 && (i - 1) >= 0 && s[i - 1] == '0') {
        for (i = a_2 - 1; i >= 0; i--) {
          if (s[i] != '0') break;
          k++;
        }
      }
      min_25 += k;
    } else if (a_2 == s.length() - 1 && s[s.length() - 2] == '0') {
      k = 0;
      for (i = s.length() - 2; i >= 0; i--) {
        if (s[i] != '0') break;
        k++;
      }
      if (i == a_5 && (i - 1) >= 0 && s[i - 1] == '0') {
        for (i = a_5 - 1; i >= 0; i--) {
          if (s[i] != '0') break;
          k++;
        }
      }
      min_25 += k;
    }
  }
  if (b_5 != -1 && b_0 != -1) {
    if (b_0 < a_5)
      min_50 = b_0 + (b_5 - 1);
    else
      min_50 = b_0 + b_5;
  }
  if (c_7 != -1 && c_5 != -1) {
    if (c_5 < c_7)
      min_75 = c_5 + (c_7 - 1);
    else
      min_75 = c_5 + c_7;
    if (c_5 == s.length() - 1 && s[s.length() - 2] == '0') {
      k = 0;
      for (i = s.length() - 2; i >= 0; i--) {
        if (s[i] != '0') break;
        k++;
      }
      if (i == c_7 && (i - 1) >= 0 && s[i - 1] == '0') {
        for (i = c_7 - 1; i >= 0; i--) {
          if (s[i] != '0') break;
          k++;
        }
      }
      min_75 += k;
    } else if (c_5 == s.length() - 1 && s[s.length() - 2] == '0') {
      k = 0;
      for (i = s.length() - 2; i >= 0; i--) {
        if (s[i] != '0') break;
        k++;
      }
      if (i == c_7 && (i - 1) >= 0 && s[i - 1] == '0') {
        for (i = c_7 - 1; i >= 0; i--) {
          if (s[i] != '0') break;
          k++;
        }
      }
      min_75 += k;
    }
  }
  if (d_0 != -1 && d_01 != -1) {
    min_00 = d_0 + d_01 - 1;
  }
  v.push_back(min_25);
  v.push_back(min_50);
  v.push_back(min_75);
  v.push_back(min_00);
  sort(v.begin(), v.end());
  if (v[0] >= maxx) v[0] = -1;
  cout << v[0] << "\n";
  return 0;
}