#include <bits/stdc++.h>
using namespace std;
int main() {
  char start = 'a', endd;
  int x = 0, diff = 0;
  string y;
  cin >> y;
  endd = y[0];
  while (y[x] != '\0') {
    x++;
  }
  for (int i = 0; i < x; i++) {
    if (abs(start - endd) > 12) {
      if (start + 13 > 122) {
        start = 97 + 12 - (122 - start);
      } else
        start += 13;
      diff += 13 - (abs(endd - start));
    } else
      diff += abs(start - endd);
    start = y[i];
    endd = y[i + 1];
  }
  cout << diff;
  return 0;
}
