gets;p$<.read.split.map{|s|$*[s.hex]?1:3}.sum/4