text: for _ in range(int(input())):
      n = int(input())
      count = 0
      while n >= 2048:
         n -= 2048
         count += 1
      while n >= 1024:
         n -= 1024
         count += 1
      while n >= 512:
         n -= 512
         count += 1
      while n >= 256:
         n -= 256
         count += 1
      while n >= 128:
         n -= 128
         count += 1
      while n >= 64:
         n -= 64
         count += 1
      while n >= 32:
         n -= 32
         count += 1
      while n >= 16:
         n -= 16
         count += 1
      while n >= 8:
         n -= 8
         count += 1
      while n >= 4:
         n -= 4
         count += 1
      while n >= 2:
         n -= 2
         count += 1
      while n >= 1:
         n -= 1
         count += 1
      print(count)