#!/usr/bin/perl -w

use v5.38;

my $sum;
while (<>) {
	my ($have, $win) = /: (.*) \| (.*)/;
	my %is_win = map { $_ => 1 } ($win =~ /(\d+)/g);
	my $count = grep { $is_win{$_} } ($have =~ /(\d+)/g);
	$sum += 1 << ($count-1) if $count;
}
say $sum;
