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