#include <fstream>
using namespace std;
ifstream f1("bai4_14.inp");
ofstream f2("bai4_14.out");
int main()
{
    long n;
    f1 >> n;
    long kq = 0,tg = 1;
    while (n > 0)
    {
        kq = kq + ((n%10) * tg);
        tg = tg * 2;
        n = n/10;
    }
    f2 << kq;
    return 0;
}
