/ /and$x+=!$s{$`}++,$y+=!${$'}++for($w,$h,@a)=<>;print$w*$y+($h-$y)*$x-$#a