import string
file = open('p22.txt', 'r')
line = file.readline()
names = line.split(",")

# format the words correctly
for i in range(len(names)):
    names[i] = names[i][1:-1]

alphabet = string.ascii_uppercase
dictionary = {}
names.sort()
for i in range(len(alphabet)):
    dictionary[alphabet[i]] = i+1

def value(word):
    answer = 0
    for char in word:
        answer += dictionary[char]
    return answer

count = 0
for i in range(len(names)):
    count += value(names[i]) * (i+1)

print(count)
49ed7e4b26bc809b47f45bbdff082b5e28aab7e0
<mask token>


def value(word):
    answer = 0
    for char in word:
        answer += dictionary[char]
    return answer


<mask token>

<mask token>
for i in range(len(names)):
    names[i] = names[i][1:-1]
<mask token>
names.sort()
for i in range(len(alphabet)):
    dictionary[alphabet[i]] = i + 1


def value(word):
    answer = 0
    for char in word:
        answer += dictionary[char]
    return answer


<mask token>
for i in range(len(names)):
    count += value(names[i]) * (i + 1)
print(count)

<mask token>
file = open('p22.txt', 'r')
line = file.readline()
names = line.split(',')
for i in range(len(names)):
    names[i] = names[i][1:-1]
alphabet = string.ascii_uppercase
dictionary = {}
names.sort()
for i in range(len(alphabet)):
    dictionary[alphabet[i]] = i + 1


def value(word):
    answer = 0
    for char in word:
        answer += dictionary[char]
    return answer


count = 0
for i in range(len(names)):
    count += value(names[i]) * (i + 1)
print(count)

import string
file = open('p22.txt', 'r')
line = file.readline()
names = line.split(',')
for i in range(len(names)):
    names[i] = names[i][1:-1]
alphabet = string.ascii_uppercase
dictionary = {}
names.sort()
for i in range(len(alphabet)):
    dictionary[alphabet[i]] = i + 1


def value(word):
    answer = 0
    for char in word:
        answer += dictionary[char]
    return answer


count = 0
for i in range(len(names)):
    count += value(names[i]) * (i + 1)
print(count)

import string
file = open('p22.txt', 'r')
line = file.readline()
names = line.split(",")

# format the words correctly
for i in range(len(names)):
    names[i] = names[i][1:-1]

alphabet = string.ascii_uppercase
dictionary = {}
names.sort()
for i in range(len(alphabet)):
    dictionary[alphabet[i]] = i+1

def value(word):
    answer = 0
    for char in word:
        answer += dictionary[char]
    return answer

count = 0
for i in range(len(names)):
    count += value(names[i]) * (i+1)

print(count)