#include <bits/stdc++.h>
using namespace std;
int main() {
  char now;
  string a;
  cin >> a;
  now = 'a';
  int ans = 0;
  for (int i = 0; a[i]; i++) {
    ans +=
        min(abs(a[i] - now), min(abs(a[i] + 26 - now), abs(now + 26 - a[i])));
    now = a[i];
  }
  printf("%d\n", ans);
  return 0;
}
