from functools import reduce

def get_file():
    names = open('../resource/names.txt', 'r').read().split(',')
    return sorted(names)

def name_score(name):
    return reduce(lambda x, y: x + ord(y) - ord('A') + 1, name, 0)

print(reduce(lambda x, y: x + (y[0] + 1) * y[1], enumerate(map(lambda x: name_score(x), get_file())), 0))