def skew(n): s = 0 i=0 while n: i += 1 t = n % 10 n = n // 10 s += t * (2**i-1) return s while True: try: n = int(input()) if n == 0: break print(skew(n)) except: break
def skew(n): s = 0 i=0 while n: i += 1 t = n % 10 n = n // 10 s += t * (2**i-1) return s while True: try: n = int(input()) if n == 0: break print(skew(n)) except: break