#include <bits/stdc++.h>
using namespace std;
int main() {
  int sum = 0, ind = 97, _final = 0;
  string cstr;
  cin >> cstr;
  for (int i = 0; i < cstr.length(); i++) {
    _final = abs(ind - cstr[i]);
    if (_final > 13) {
      _final = 26 - _final;
    }
    ind = cstr[i];
    sum += _final;
  }
  cout << sum << endl;
  return 0;
}
