def count_Num(n):
    if n == 0:
        return 1
    # Numbers where both bit 0 (LSB) and bit n are set
    # Such numbers have the form: ...X...X...1 where bit n and bit 0 are set
    # In range of numbers with n+1 bits, we need bit 0 and bit n both set
    # The count of n-bit numbers (from 0 to 2^n - 1) where bit 0 and bit n are set
    # Bit 0 and bit n set means the number has the pattern where positions 0 and n are 1
    # The remaining n-1 bits (bits 1 to n-1) can be anything
    # So count = 2^(n-1)
    return 2 ** (n - 1)