#include <bits/stdc++.h>
int main(int argc, const char* argv[]) {
  char str[101];
  gets(str);
  int current = 1, sum = 0, tmp = 0, tmp1 = 0, tmp2 = 0;
  for (int i = 0; str[i] != '\0'; i++) {
    tmp = str[i] - 'a' + 1;
    tmp1 = abs(tmp - current);
    tmp2 = 26 - tmp1;
    if (tmp2 < tmp1) tmp1 = tmp2;
    sum += tmp1;
    current = tmp;
  }
  printf("%d", sum);
  return 0;
}
