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