#include <bits/stdc++.h>
const int N = 105;
using namespace std;
int main() {
  string a;
  char letter = 'a';
  int total = 0;
  cin >> a;
  for (int i = 0; i < a.size(); i++) {
    total += min(abs(letter - a[i]), 26 - abs((letter - a[i])));
    letter = a[i];
  }
  cout << total << endl;
}
