#include "iostream" #include "stdio.h" #include "string.h" using namespace std; int main() { char input[50]; int num[50], len, i, ans, temp, tag; while (scanf("%s", input)) { memset(num, 0, sizeof(num)); ans = 0, temp = 2, tag = 1; if (strcmp(input, "0") == 0) break; len = strlen(input); for (i = 0; i < len; i++) num[len-i-1] = input[i] - 48; for (i = 0; i < len; i++) { ans += num[i] * (temp - 1); temp *= 2; if (ans > 2147483647) { cout << 2147483647 << endl; tag = 0; break; } } if (tag) cout << ans << endl; } }