lines = open("input.txt", 'r').read().splitlines()

sum = 0
sum2 = 0

for l in lines:
    match(l):
        case "A X":
            sum += 4
            sum2 += 3
        case "A Y":
            sum += 8
            sum2 += 4
        case "A Z":
            sum += 3
            sum2 += 8
        case "B X":
            sum += 1
            sum2 += 1
        case "B Y":
            sum += 5
            sum2 += 5
        case "B Z":
            sum += 9
            sum2 += 9
        case "C X":
            sum += 7
            sum2 += 2
        case "C Y":
            sum += 2
            sum2 += 6
        case "C Z": 
            sum += 6
            sum2 += 7
print(sum)
print(sum2)