#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  char r = 'a', l;
  int m = 0;
  cin >> n;
  for (int i = 0; i < n.size(); i++) {
    if (abs((int)(r - n[i])) <= 13)
      m += abs((int)(r - n[i]));
    else {
      l = (r > n[i] ? r : n[i]);
      r = (r < n[i] ? r : n[i]);
      m += (int)('z' - l + 1 + r - 'a');
    }
    r = n[i];
  }
  cout << m;
  return 0;
}
