#include <bits/stdc++.h>
using namespace std;
int main() {
  int sum = 0;
  string str;
  cin >> str;
  if ((str[0] - 'a') > 13)
    sum += 26 - (str[0] - 'a');
  else
    sum += (str[0] - 'a');
  for (int i = 1; i < str.size(); i++) {
    int x = (str[i - 1] - 'a'), y = (str[i] - 'a');
    if (abs(x - y) > 13) {
      int min = x < y ? x : y;
      if (min < 13) min += 26;
      sum += min - (x > y ? x : y);
    } else
      sum += abs(x - y);
  }
  cout << sum;
  return 0;
}
