$a=<>+<>; <>; for(<>){ $s+=$a if$h[$_]++; } print$s+0