#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int sum = 0;
  map<char, int> m;
  for (char i = 'a'; i <= 'z'; i++) {
    if (i == 'a')
      m[i] = 0;
    else
      m[i] = (int)i - 97;
  }
  if (s.size() == 1) {
    if (abs(0 - m[s[0]]) >= 13)
      sum += 26 - (abs(0 - m[s[0]]));
    else
      sum += (abs(0 - m[s[0]]));
    cout << sum;
    return 0;
  }
  for (int i = 0; i < s.size() - 1; i++) {
    if (i == s.size() - 1) break;
    if (i == 0) {
      if (abs(0 - m[s[i]]) >= 13)
        sum += 26 - (abs(0 - m[s[i]]));
      else
        sum += (abs(0 - m[s[i]]));
    }
    if (abs(m[s[i]] - ((int)s[i + 1] - 97)) >= 13)
      sum += 26 - (abs(m[s[i]] - ((int)s[i + 1] - 97)));
    else
      sum += abs(m[s[i]] - ((int)s[i + 1] - 97));
  }
  cout << sum;
  return 0;
}
