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;
const int N = 1e5 + 5, inf = 0x3f3f3f3f;
long long n;
int a[20], b[20], last;
vector<int> p[10];
void split(long long n) {
  while (n) {
    a[++last] = n % 10;
    b[last] = a[last];
    n /= 10;
  }
}
long long move(int src, int dest) {
  a[dest] = a[src];
  for (int i = src; i > dest; i--) a[i] = a[i - 1];
  return src - dest;
}
int findNoZero() {
  if (last == 2) return last;
  for (int i = last; i > 2; i--)
    if (a[i] > 0) return i;
  return -1;
}
long long trans(int d1, int d2) {
  for (int i = 1; i <= last; i++) a[i] = b[i];
  long long ans = 0;
  if (d1 == 0 && d2 == 0) {
    if (p[0].size() < 2) return inf;
    return p[0][0] - 1 + p[0][1] - 2;
  }
  if (p[d1].empty() || p[d2].empty()) return inf;
  if (p[d2][0] < p[d1][0]) {
    ans += move(p[d2][0], 1);
    ans += move(p[d1][0], 1);
  } else {
    ans += move(p[d1][0], 1);
    ans += move(p[d2][0], 2);
  }
  int noZero = findNoZero();
  if (noZero == -1) return inf;
  return ans + last - noZero;
}
long long solve() {
  if (n <= 100) {
    if (n == 100 || n == 75 || n == 50 || n == 25) return 0;
    if (n == 57 || n == 52)
      return 1;
    else
      return -1;
  }
  split(n);
  for (int i = 1; i <= last; i++) p[a[i]].push_back(i);
  long long ans = inf;
  ans = min(ans, trans(0, 0));
  ans = min(ans, trans(5, 2));
  ans = min(ans, trans(0, 5));
  ans = min(ans, trans(5, 7));
  return ans == inf ? -1 : ans;
}
int main() {
  cin >> n;
  cout << solve() << endl;
  return 0;
}