#!/usr/local/gnu/bin/bash
read s
sarr=(`echo $s | fold -1`)
len=${#s}
mularr=(1 2 4 8 16 32 64 128 256)
num=0
for((i=0;i<len;i++))
do
    tmpnum=$((mularr[i]*sarr[i]))
    for((j=i+1;j<len;j++))
    do
        tmpnum=$((tmpnum*10+mularr[j-1]*sarr[i]))
    done
    num=$((num+tmpnum))
done
echo $num
