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