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