#!/usr/bin/python3 import sys priority = {} p = 1 for c in 'abcdefghijklmnopqrstuvwxyz': priority[c] = p p += 1 for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': priority[c] = p p += 1 total = 0 lines = sys.stdin.readlines() for i in range(0, len(lines), 3): first = set(list(lines[i].rstrip())) second = set(list(lines[i+1].rstrip())) third = set(list(lines[i+2].rstrip())) inter = first & second & third total += priority[inter.pop()] print(total)