//土尔逊Torson 编写于2023/4/18
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdarg>
#include <string>
#include <stdlib.h>
using namespace std;
int main() {
string str1;
while (cin >> str1) {
int answer = 0;
for (int i = 0, j = str1.size(); i < str1.size(), 0 < j; ++i, --j) {
answer += (str1[i] - '0') * ((2 << (j-1)) - 1);
//printf("str1[%d] - '0' = %d\n", i, str1[i]-'0');
//printf("2^%d = %d\n", j,2 ^ j);
//printf("answer[%d] = %d\n", i, answer);
}
printf("%d\n", answer);
}
system("pause");
return EXIT_SUCCESS;
}
// 64 位输出请用 printf("%lld")