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 check(string str, char c1, char c2) {
  int an = 0;
  bool f1 = false;
  bool f2 = false;
  int i;
  for (i = str.length() - 1; i >= 0; i--) {
    if (str.at(i) == c2) {
      f1 = true;
      break;
    }
    an += 2;
  }
  if (!f1) {
    return 1000000007;
  }
  i--;
  for (; i >= 0; i--) {
    if (str.at(i) == c1) {
      f2 = true;
      break;
    }
    an++;
  }
  if (!f2) {
    return 1000000007;
  }
  return an;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin >> str;
  int to5 = -10;
  int to0 = -10;
  for (int i = str.length() - 1; i >= 0; i--) {
    if (str.at(i) == '5' && to5 == -10) {
      to5 = str.length() - 1 - i;
    }
    if (str.at(i) == '0' && to0 == -10) {
      to0 = str.length() - 1 - i;
    }
  }
  if (to5 == -10 && to0 == -10) {
    cout << -1;
    return 0;
  }
  int to00 = -10;
  int to50 = -10;
  int to25 = -10;
  int to75 = -10;
  if (to5 != -10) {
    for (int i = str.length() - 1; i >= 0; i--) {
      if (str.at(i) == '2' && to25 == -10) {
        to25 = str.length() - 2 - i;
      }
      if (str.at(i) == '7' && to75 == -10) {
        to75 = str.length() - 2 - i;
      }
    }
  }
  if (to0 != -10) {
    bool was1 = false;
    for (int i = str.length() - 1; i >= 0; i--) {
      if (str.at(i) == '0' && to00 == -10) {
        if (was1) {
          to00 = str.length() - 2 - i;
        } else {
          was1 = true;
        }
      }
      if (str.at(i) == '5' && to50 == -10) {
        to50 = str.length() - 2 - i;
      }
    }
  }
  if (to00 == -10 && to50 == -10 && to25 == -10 && to75 == -10) {
    cout << -1;
    return 0;
  }
  int ans = 1000000007;
  if (to00 != -10) {
    ans = min(to0 + to00, ans);
  }
  if (to50 != -10) {
    if (to0 > to50) {
      to50++;
    }
    ans = min(to0 + to50, ans);
  }
  if (to25 != -10) {
    if (to5 > to25) {
      to25++;
    }
    if (to5 == str.length() - 1 && str.at(1) == '0') {
      int i = 1;
      while (str.at(i) == '0') {
        i++;
      }
      to25 += i - 1;
    }
    ans = min(to5 + to25, ans);
  }
  if (to75 != -10) {
    if (to5 > to75) {
      to75++;
    }
    if (to5 == str.length() - 1 && str.at(1) == '0') {
      int i = 1;
      while (str.at(i) == '0') {
        i++;
      }
      to75 += i - 1;
    }
    ans = min(to5 + to75, ans);
  }
  cout << ans;
  return 0;
}