#include <iostream> using namespace std; //构建判定分组的辅助数组和判定次数的辅助数组 int main() { string str; while (cin >> str) { int len = str.length(); int cnt = 0; int pd[26]; int cost[26]; for (int i = 0; i < 26; i++) { if (i <= 14) { pd[i] = i / 3; cost[i] = i % 3 + 1; } else if (i > 14 and i <= 18) { pd[i] = 5; //pqrs属于第5组 cost[i] = i - 14; } else if (i > 18 and i <= 21) { pd[i] = 6; cost[i] = i - 18; } else { pd[i] = 7; cost[i] = i - 21; } } for (int i = 0; i < len - 1; i++) { int num1 = str[i] - 'a'; int num2 = str[i + 1] - 'a'; if (pd[num1] == pd[num2]) cnt += 2; cnt += cost[num1]; } cnt += cost[str[len-1]-'a']; cout << cnt << endl; } } // 64 位输出请用 printf("%lld")