for i in range(1, 1000): x = i L = 0 M = 0 while x > 0: M += 1 if x % 2 != 0: L += x % 8 x //= 8 if L == 21 and M == 3: print(i)