#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int sum = 0, d = 0, diff = 0;
  int start = 97;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    diff = abs((int)s[i] - start);
    if (diff > 13) {
      d = 26 - diff;
      sum += d;
    } else {
      sum += diff;
    }
    start = (int)s[i];
  }
  cout << sum;
  return 0;
}
