#include <iostream>
#include <string>
#include <cmath>//记得加cmath
using namespace std;
int main() {
int a, b;
string str1;
//getline获得一行 以换行符为结束符!
while (getline(cin, str1)) { // 注意 while 处理多个 case
int sum=0;
// char->int 只需要char-'0'(48){ascall码转换)反之亦然。
for (int i = 0,j=str1.length(); i<str1.length(); i++,j--) {
//string括号嵌套别搞错了
sum+=(str1[i]-'0')*(pow(2,j)-1);
}
cout<<sum<<endl;
}
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号