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