#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  string s;
  cin >> s;
  n = s.size();
  char t = 'a';
  for (int i = 0; i < n; i++) {
    int x;
    x = abs(s[i] - t);
    if (x < abs(x - 26))
      ans += x;
    else
      ans += abs(26 - x);
    t = s[i];
  }
  cout << ans;
}
