# Programmer: Sikder Huq and Sriram Pemmaraju
# Date: Feb 16, 2014

# Get input
n = int(raw_input())

dec = 0 # we will build the decimal equivalent in this variable
placeValue  = 1 # the place value of the right most bit is 1


# Repeatedly extract bits from n, right-to-left
while n > 0:
    bit = n % 10 # get the rightmost bit
    dec = dec + bit * placeValue # update dec by the value of the bit that was just extracted
    placeValue = placeValue * 2 # update place value
    n = n / 10 # everything except the last digit is reassigned to n

print dec
    
    
