import sys


def get_priority(item):
    if item.islower():
        return ord(item) - ord("a") + 1
    elif item.isupper():
        return ord(item) - ord("A") + 27
    else:
        assert False


def main():
    rucksacks = [set(line.strip()) for line in sys.stdin]
    result = 0

    for i in range(0, len(rucksacks), 3):
        a, b, c = rucksacks[i : i + 3]
        [item] = a & b & c
        result += get_priority(item)

    print(result)


if __name__ == "__main__":
    main()
