#include <cmath> #include <iostream> #include <string> using namespace std; int main() { string a; while (cin >> a) { // 注意 while 处理多个 case if (a == "0") break; long k = 0; for (int i = a.size() - 1; i >= 0; i--) { int m = (a[i] - '0') * (pow(2, a.size() - i) - 1); k += m; } cout << k << endl; } } // 64 位输出请用 printf("%lld")