#include <bits/stdc++.h>
using namespace std;
int main() {
  string input_word;
  cin >> input_word;
  int answer = 0;
  char current = 'a';
  for (char c : input_word) {
    int will_be_added;
    will_be_added = abs(current - c);
    current = c;
    will_be_added = (will_be_added > 13) ? (26 - will_be_added) : will_be_added;
    answer += will_be_added;
  }
  cout << answer << '\n';
  ;
  return 0;
}
