#include <bits/stdc++.h>
using namespace std;
int main() {
  string abc = "abcdefghijklmnopqrstuvwxyz";
  string cba = "azyxwvutsrqponmlkjihgfedcb";
  string input;
  cin >> input;
  int count1[110], count2[110];
  int count3 = 0, count4 = 0;
  int p = 0, q = 0;
  int d = 0;
  int sum = 0;
  for (int i = 0; i < input.length(); i++) {
    for (int j = d; j < abc.length(); j++) {
      if (input[i] == abc[j]) {
        count1[p] = count3;
        d = 25 - (25 - j);
        count3 = 0;
        p++;
        break;
      }
      if (j == (abc.length() - 1)) {
        d = 0;
        i--;
      }
      count3++;
    }
  }
  d = 0;
  for (int i = 0; i < input.length(); i++) {
    for (int j = d; j < cba.length(); j++) {
      if (input[i] == cba[j]) {
        count2[q] = count4;
        d = 25 - (25 - j);
        count4 = 0;
        q++;
        break;
      } else if (j == (cba.length() - 1)) {
        d = 0;
        i--;
      }
      count4++;
    }
  }
  for (int i = 0; i < input.length(); i++) {
    if (count1[i] <= count2[i])
      sum += count1[i];
    else
      sum += count2[i];
  }
  cout << sum << endl;
}
