#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  string s;
  cin >> s;
  char x = 'a';
  abs(x - s[0]) > 13 ? ans += 26 - abs(x - s[0]) : ans += abs(x - s[0]);
  for (int i = 0; i < s.length() - 1; i++) {
    abs(s[i] - s[i + 1]) > 13 ? ans += (26 - abs(s[i] - s[i + 1]))
                              : ans += abs(s[i] - s[i + 1]);
  }
  cout << (ans);
}
