#include <bits/stdc++.h>
using namespace std;
int main() {
  string in = "smm";
  cin >> in;
  int a = 97, z = 122, sum = 0, check, length = in.length();
  char inp[length];
  int f[length];
  for (int i = 0; i < length; i++) {
    inp[i] = in.at(i);
    f[i] = (int)inp[i];
  }
  check = f[0] - a;
  if (check > z - f[0] + 1) {
    check = z - f[0] + 1;
  }
  sum += check;
  for (int i = 1; i < length; i++) {
    if (f[i] - f[i - 1] >= 0) {
      if (f[i] - f[i - 1] > 13) {
        sum += 26 - (f[i] - f[i - 1]);
      } else {
        sum += f[i] - f[i - 1];
      }
    } else {
      if (f[i - 1] - f[i] > 13) {
        sum += 26 - (f[i - 1] - f[i]);
      } else {
        sum += f[i - 1] - f[i];
      }
    }
  }
  cout << sum;
}
