#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c = 0, n, m = 0;
  string s;
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i++) {
    a = s[i] - 97;
    b = abs(c - a);
    if (b > 13)
      m = m + 26 - b;
    else
      m = m + b;
    c = a;
  }
  cout << m;
  return 0;
}
