#include <bits/stdc++.h>   using namespace std;   int main() {     int sum = 0, pos = 0;     string s;     cin >> s;     for (int i = 0; i < s.length(); i++)       sum += min(abs(pos - (s[i] -  a )), 26 - abs(pos - (s[i] -  a ))),           pos = s[i] -  a ;     cout << sum;     return 0;   }   