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