#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, s, d;
  string mot;
  cin >> mot;
  while (mot.size() > 100) {
    cin >> mot;
  }
  d = abs(mot[0] - 'a');
  if (d <= 13) {
    s = d;
  } else {
    s = 26 - d;
  }
  for (i = 0; i < mot.size() - 1; i++) {
    d = abs(mot[i + 1] - mot[i]);
    if (d <= 13) {
      s += d;
    } else {
      s += 26 - d;
    }
  }
  cout << s;
}
