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