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