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