#include <bits/stdc++.h>
using namespace std;
int main() {
  string name = "a";
  string input;
  cin >> input;
  name += input;
  int Result = 0;
  for (int i = 0; i < name.length() - 1; i++) {
    Result += (abs(name[i + 1] - name[i]) > 13)
                  ? (26 - abs((name[i + 1]) - name[i]))
                  : abs((name[i + 1] - name[i]));
  }
  cout << Result;
  return 0;
}
