class Solution:
def minTimeToType(self, word: str) -> int:
word = 'a' + word
ans = 0
for i in range(1, len(word)):
tmp = abs(ord(word[i]) - ord(word[i-1]))
if tmp > 13:
ans = ans + (26 - tmp) % 26
else:
ans = ans + tmp % 26
return ans + len(word) - 1