#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
vector<pair<string, int>> v;
bool sortbysec(const pair<string, int>& a, const pair<string, int>& b) {
  return (a.second < b.second);
}
int main() {
  string s;
  cin >> s;
  int n = 26;
  char start = 'a';
  int ans = 0;
  int dif = 0;
  for (int i = 0; i < s.size(); ++i) {
    dif = abs(start - s[i]);
    if (dif > 13) {
      dif = n - dif;
    }
    ans += dif;
    start = s[i];
  }
  cout << ans << endl;
  return 0;
}
