$T=<>;<>; for$c(glob<>){$/=$"; for($v=<>;$v;$v>>=1){ for$t(reverse$c..$T){ $d[$t]+=$-=$d[$t-$c]+$v-$d[$t] } } } print$d[-1]+0