perl -e "print eval join '+',grep{(0.5*(4*$_+1-(-1)**scalar @{[((sprintf '%b',$_)=~/1/g)]}))%2==0} 0..$ARGV[0];" 10 33