#include <fstream>
#include <string>

using namespace std;

ifstream input("Bai4_14.inp");
ofstream output("Bai4_14.out");
long long res;
string n;

void decToBin()
{
	long long index = 1;
	for (int i = n.size() - 1; i >= 0; --i)
	{
		res += (n[i] - '0') * index;
		index <<= 1;
	}
}

int main()
{
	input >> n;
	decToBin();
	output << res;
	input.close();
	output.close();
	return 0;
}