#include <bits/stdc++.h>
char s[105];
int main() {
  char s[105];
  int len, sum = 0, q, i;
  scanf("%s", s + 1);
  s[0] = 'a';
  len = strlen(s);
  for (i = 1; i < len; i++) {
    q = s[i] - s[i - 1];
    if (q < 0) q = -1 * q;
    if (q > 13) q = 26 - q;
    sum = sum + q;
  }
  printf("%d\n", sum);
}
