#include <bits/stdc++.h>
using namespace std;
string s;
int k, S, t;
int main() {
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    k = abs((s[i] - 'a') - t);
    if (k > 13) k = 26 - k;
    S += k;
    t = (s[i] - 'a');
  }
  cout << S;
  return 0;
}
