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