def hitungNomorBit(angka, nomorBit):
    if nomorBit != 0 and nomorBit != 1:
        return None

    if angka < 0:
        return None

    if angka == 0:
        return 1 if nomorBit == 0 else 0

    jumlah = 0

    while angka > 0:
        bit = angka % 2

        if bit == nomorBit:
            jumlah += 1

        angka //= 2

    return jumlah


print(hitungNomorBit(13, 0))
print(hitungNomorBit(13, 1))
print(hitungNomorBit(13, 2))
