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