#include using namespace std; int main() { // Reading input freopen("controller.in", "r", stdin); freopen("controller.out", "w", stdout); string s, f; cin >> s; cin >> f; int totalMoves = 0; for (int i = 0; i < s.size(); ++i) { // Convert characters to their respective positions in the alphabet (0-based index) int start = s[i] - 'a'; int end = f[i] - 'a'; // Calculate forward and backward distances int forwardMove = abs(end - start); int backwardMove = 26 - forwardMove; // The minimal moves for this character totalMoves += min(forwardMove, backwardMove); } cout << totalMoves << endl; return 0; }