#include <bits/stdc++.h>
using namespace std;
int diff1, diff2, ans;
string s;
char ch = 'a';
int main() {
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    diff1 = abs(ch - s[i]);
    diff2 = 26 - diff1;
    ans += min(diff1, diff2);
    ch = s[i];
  }
  printf("%d\n", ans);
  return 0;
}
