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