#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, k = 0;
  string s;
  cin >> s;
  if (abs(97 - s[0]) <= abs(26 - abs(97 - s[0]))) {
    k = abs(97 - s[0]);
  } else {
    k = abs(26 - abs(97 - s[0]));
  }
  for (i = 0; i < s.length() - 1; i++) {
    if (abs(s[i + 1] - s[i]) <= abs(26 - abs(s[i + 1] - s[i]))) {
      k += abs(s[i + 1] - s[i]);
    } else {
      k += abs(26 - abs(s[i + 1] - s[i]));
    }
  }
  cout << k;
  return 0;
}
