def s_bit_cost(v):
    """
    Max bits required to represent up to the given number
    """
    if v>=64: return  7
    if v>=32: return  6
    if v>=16: return  5
    if v>=8: return 4
    if v>=4: return 3
    if v>=2: return 2
    if v>=1: return 1
    return 0