import math def log2(x): return int(math.ceil(math.log(x,2)))