#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  string s;
  cin >> s;
  int curr = 1, count = 0;
  for (int i = 0; i < s.length(); i++) {
    int index = int(s[i]) - 96;
    if (abs(index - curr) <= 13) {
      count += abs(index - curr);
    } else {
      count += 26 - abs(index - curr);
    }
    curr = index;
  }
  cout << count;
  return 0;
}
