#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = (int)s.length(), count = 0;
  char c = 'a';
  for (int i = 0; i < len; i++) {
    if (c >= s[i]) {
      count += min(c - s[i], ('z' - c) + (s[i] - 'a') + 1);
    } else {
      count += min(s[i] - c, (c - 'a') + ('z' - s[i]) + 1);
    }
    c = s[i];
  }
  cout << count << endl;
  return 0;
}
