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