#include <bits/stdc++.h>
int main() {
  char word[100];
  gets(word);
  int rot = 0;
  char prev = 'a';
  for (int i = 0; word[i] != '\0'; i++) {
    int dif = abs(word[i] - prev);
    rot += dif > 13 ? 26 - dif : dif;
    prev = word[i];
  }
  printf("%d", rot);
  return 0;
}
