#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  char pos = 97;
  for (int i = 0; i < s.length(); i++) {
    if (abs(pos - s[i]) > 13) {
      if (s[i] < 110) {
        ans = ans + abs((123 - pos)) + (abs(s[i] - 97));
        pos = s[i];
      } else {
        ans = ans + abs((123 - s[i])) + abs((pos - 97));
        pos = s[i];
      }
    } else {
      ans = ans + abs(pos - s[i]);
      pos = s[i];
    }
  }
  cout << ans << endl;
  return 0;
}
