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