#include <stdio.h> #include <string.h> #include <math.h>
const int MAXN = 100; char x[MAXN];
int main() { while (scanf("%s", x)!=EOF) { int ans = 0, j = 0, tail = 1; int length = strlen(x); for (int i = length; i >= 0; i--) { if (x[i] == 0 && tail == 1) continue; else { j++; tail = 0; ans += (x[i] - '0')*(pow(2, j + 0.0) - 1); } } printf("%d\n", ans); } return 0; }