func_code_string: #include <bits/stdc++.h>   using namespace std;   inline long long power(long long a, long long b) {     long long x = 1;     a = a % 1000000007ULL;     while (b) {       if (b & 1) x = (x * a) % 1000000007ULL;       a = (a * a) % 1000000007ULL;       b >>= 1;     }     return x;   }   inline long long inv(long long a) { return power(a, 1000000007ULL - 2); }   long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }   const int N = 1e5 + 5;   string s;   vector<int> v[12];   int n;   int main() {     ios_base::sync_with_stdio(false);     cin >> s;     n = s.size();     for (int i = 0; i < n; i++) {       v[s[i] -  0 ].push_back(i);     }     if (n < 2) {       cout <<  -1 n ;       return 0;     }     if (n == 2) {       if (v[0].size() > 0 && v[5].size() > 0) {         if (s[0] ==  5 )           cout <<  0 n ;         else           cout <<  1 n ;         return 0;       }       if (v[2].size() > 0 && v[5].size() > 0) {         if (s[0] ==  2 )           cout <<  0 n ;         else           cout <<  1 n ;         return 0;       }       if (v[7].size() > 0 && v[5].size() > 0) {         if (s[0] ==  7 )           cout <<  0 n ;         else           cout <<  1 n ;         return 0;       }       cout <<  -1 n ;       return 0;     }     int ans = 10000;     if (v[0].size() > 1) {       int x = v[0].size();       ans = min(ans, abs(n - 1 - v[0][x - 1]) + abs(n - 2 - v[0][x - 2]));     }     if (v[2].size() > 0 && v[5].size() > 0) {       int x = v[2].size();       int y = v[5].size();       x = v[2][x - 1];       y = v[5][y - 1];       if (n != 3 || v[0].size() == 0) {         int tmp = 0;         string sss = s;         for (int i = y; i < n - 1; i++) {           sss[i] = sss[i + 1];           tmp++;         }         sss[n - 1] =  5 ;         for (int j = n - 2; j > -1; j--) {           if (sss[j] ==  2 ) {             x = j;             break;           }         }         for (int i = x; i < n - 2; i++) {           sss[i] = sss[i + 1];           tmp++;         }         sss[n - 2] =  2 ;         if (sss[0] ==  0 ) {           for (int j = 0; j < n; j++) {             if (sss[j] ==  0 ) tmp++;           }         }         ans = min(tmp, ans);       }     }     if (v[7].size() > 0 && v[5].size() > 0) {       int x = v[7].size();       int y = v[5].size();       x = v[7][x - 1];       y = v[5][y - 1];       if (n != 3 || v[0].size() == 0) {         int tmp = 0;         string sss = s;         for (int i = y; i < n - 1; i++) {           sss[i] = sss[i + 1];           tmp++;         }         sss[n - 1] =  5 ;         for (int j = n - 2; j > -1; j--) {           if (sss[j] ==  7 ) {             x = j;             break;           }         }         for (int i = x; i < n - 2; i++) {           sss[i] = sss[i + 1];           tmp++;         }         sss[n - 2] =  7 ;         if (sss[0] ==  0 ) {           for (int j = 0; j < n; j++) {             if (sss[j] ==  0 ) tmp++;           }         }         ans = min(tmp, ans);       }     }     if (v[5].size() > 0 && v[0].size() > 0) {       int x = v[5].size();       int y = v[0].size();       x = v[5][x - 1];       y = v[0][y - 1];       if (n != 3 || v[0].size() == 1) {         int tmp = 0;         string sss = s;         for (int i = y; i < n - 1; i++) {           sss[i] = sss[i + 1];           tmp++;         }         sss[n - 1] =  0 ;         for (int j = n - 2; j > -1; j--) {           if (sss[j] ==  5 ) {             x = j;             break;           }         }         for (int i = x; i < n - 2; i++) {           sss[i] = sss[i + 1];           tmp++;         }         sss[n - 2] =  5 ;         if (sss[0] ==  0 ) {           for (int j = 0; j < n; j++) {             if (sss[j] ==  0 ) tmp++;           }         }         ans = min(tmp, ans);       }     }     if (ans == 10000) {       cout <<  -1 n ;       return 0;     }     cout << ans << endl;     return 0;   }   