#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[120];
  long long len, sum;
  s[0] = 'a';
  while (~scanf("%s", s + 1)) {
    len = strlen(s + 1);
    sum = 0;
    for (int i = 0; i <= len - 1; i++) {
      sum = sum + min(abs(s[i] - s[i + 1]),
                      'z' - max(s[i], s[i + 1]) + min(s[i], s[i + 1]) - 96);
    }
    printf("%lld\n", sum);
  }
}
