#include <stdio.h>
#include<math.h>
// 计算字符串长度:
int Length(char a[]) {
    int n = 0;
    for (int i = 0; a[i] != '\0'; i++) {
        n++;
    }
    return n;
}
int main() {
    char a[30] = "";
    while ((scanf("%s", a)) != EOF) {
        int len = Length(a);
        int sum = 0;
        int i = 0;
        while (len--) {
            sum += ((a[i++] - '0') * (pow(2, len + 1) - 1));
        }
        printf("%d\n", sum);
    }
    return 0;
}