class Solution(object):
def minTimeToType(self, word):
d = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
word = 'a' + word
res = len(word)
for i in range(0,len(word)-1):
start_index = d.index(word[i])
end_index = d.index(word[i+1])
distance = min(abs(end_index - start_index), len(d) - abs(end_index - start_index))
res += distance
return res -1