class Solution:
def hammingWeight(self, n: int) -> int:
count = 0
while True:
remainder = n % 2
n //= 2
if remainder == 1:
count += 1
if n == 0:
break
return count