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;
string str;
void cal(char c1, char c2, int &res) {
  int x1 = -1, x2 = -1;
  int n = str.size();
  for (int i = n - 1; i >= 0; i -= 1) {
    if (str[i] == c1)
      x1 = max(x1, i);
    else if (str[i] == c2)
      x2 = max(x2, i);
  }
  if (x1 != -1 && x2 != -1 && x1 != x2) {
    if (x1 < x2) {
      int add = 0;
      if (x1 == 0) {
        int k = x1 + 1;
        while (k < n) {
          if (k == x2 || str[k] == '0')
            k += 1;
          else
            break;
        }
        if (k < n || n == 2) {
          if (k < x2)
            k -= 1;
          else
            k -= 2;
          add = k;
        }
      }
      res = min(res, (n - x2 - 1) + (n - x1 - 1 - 1) + add);
    } else {
      int add = 0;
      if (x2 == 0) {
        int k = x2 + 1;
        while (k < n) {
          if (k == x1 || str[k] == '0')
            k += 1;
          else
            break;
        }
        if (k < n || n == 2) {
          if (k < x1)
            k -= 1;
          else
            k -= 2;
          add = k;
        }
      }
      res = min(res, (n - x2 - 1) + (n - x1 - 1 - 1 + 1) + add);
    }
  }
}
int main() {
  cin >> str;
  int res = 1e9;
  cal('2', '5', res);
  cal('5', '0', res);
  cal('7', '5', res);
  int n = str.size();
  for (int i = n - 1; i >= 0; i -= 1) {
    if (str[i] == '0') {
      for (int j = i - 1; j >= 0; j -= 1) {
        if (str[j] == '0') {
          res = min(res, n - i - 1 + n - j - 1 - 1);
        }
      }
    }
  }
  if (res == 1e9)
    cout << -1;
  else
    cout << res << endl;
}