#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define len 2000

int chartoint(char c){
    int a = c-'0';
    if(a>=0&&a<=9){
        return a;
    }
    return -1;
}

int main(){
    char str[len];
    while(scanf("%s",str)!=EOF){
        int n = strlen(str);
        int res = 0;
        for(int i = 0;i<n;i++){
            res+=chartoint(str[i])*(pow(2,n-i)-1);
        }
        printf("%d\n",res);
    }
}