#include <stdio.h>
#include<string.h>
#include <math.h>
int main() {
	char skew[32] = { 0 };
	while (scanf("%[^\n]%*c", skew) != EOF) {
		//printf("%d\n", skew[1]-'0');
		int number=0;
		for (int i = 0; i < strlen(skew); i++) {
			number += (skew[i]-'0') * (pow(2,(strlen(skew) - i)) - 1);
		}
		printf("%d\n", number);
	}
	return 0;
}