#include <bits/stdc++.h>
using namespace std;
int main() {
  string word;
  cin >> word;
  int dist, res = 0;
  char cur = 'a';
  for (int i = 0; i < word.length(); ++i) {
    dist = abs(word[i] - cur);
    res += (dist < 13) ? dist : 26 - dist;
    cur = word[i];
  }
  cout << res;
  return 0;
}
