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