""" day_04_01.py """

# usage: python3 day_04_01.py < input

import sys


def process(text):
    """ card # and matches """
    label, game = text.split(': ')
    _, seq = label.split()
    x, y = game.split(' | ')
    return seq, len(set(x.split()) & set(y.split()))


answer = 0
for line in sys.stdin:
    _, matches = process(line)
    if matches > 0:
        answer += pow(2, matches - 1)

print(answer)
