#!/usr/bin/env python3 import sys sum = 0 for line in sys.stdin: _, nums = line.split(":") winning, mine = nums.split("|") winning = set(winning.split()) if len(winning) != len(set(winning)): raise ValueError("Shenannigans!") mine = set(mine.split()) if len(mine) != len(set(mine)): raise ValueError("Shenannigans! {}".format(mine)) both = winning.intersection(mine) c = len(both) if c > 0: sum += 2 ** (c - 1) print(sum)