#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
char numb[30],*temp=numb;
int n=0,tn=0;
fgets(numb,30,stdin);
while(*(temp+1)!='\0') //шукаємо останній символ рядка
{
temp++;
}
for(char* i=temp;i>=numb;i--)
{
int m=0;
int tempnumb=0;
while(*i!=' ') // проходимо циклом по кожній тетраді
{
if(*i=='1')
tempnumb+=pow(2,m);// тут формуємо десяткове представлення тетради
i--;
m++;
}
tn+=tempnumb*pow(10,n);//тут додаємо розряд тетради
cout << n << endl;
n++;
}
cout<<tn;
//cin.ignore();
//cin.get();
return 0;
}
I2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8aW9zdHJlYW0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCmludCBtYWluKCkgewogICAgY2hhciBudW1iWzMwXSwqdGVtcD1udW1iOwogICAgaW50IG49MCx0bj0wOwogICAgZmdldHMobnVtYiwzMCxzdGRpbik7CiAgICB3aGlsZSgqKHRlbXArMSkhPSdcMCcpIC8v0YjRg9C60LDRlNC80L4g0L7RgdGC0LDQvdC90ZbQuSDRgdC40LzQstC+0Lsg0YDRj9C00LrQsAogICAgewogICAgICAgIHRlbXArKzsKICAgIH0KICAgIGZvcihjaGFyKiBpPXRlbXA7aT49bnVtYjtpLS0pIAogICAgewogICAgICAgIGludCBtPTA7CiAgICAgICAgaW50IHRlbXBudW1iPTA7CiAgICAgICAgd2hpbGUoKmkhPScgJykgLy8g0L/RgNC+0YXQvtC00LjQvNC+INGG0LjQutC70L7QvCDQv9C+INC60L7QttC90ZbQuSDRgtC10YLRgNCw0LTRlgogICAgICAgIHsKICAgICAgICAgICAgaWYoKmk9PScxJykgCiAgICAgICAgICAgICAgICB0ZW1wbnVtYis9cG93KDIsbSk7Ly8g0YLRg9GCINGE0L7RgNC80YPRlNC80L4g0LTQtdGB0Y/RgtC60L7QstC1INC/0YDQtdC00YHRgtCw0LLQu9C10L3QvdGPINGC0LXRgtGA0LDQtNC4CiAgICAgICAgICAgIGktLTsKICAgICAgICAgICAgbSsrOwogICAgICAgIH0KICAgICAgICB0bis9dGVtcG51bWIqcG93KDEwLG4pOy8v0YLRg9GCINC00L7QtNCw0ZTQvNC+INGA0L7Qt9GA0Y/QtCDRgtC10YLRgNCw0LTQuAogICAgICAgIGNvdXQgPDwgbiA8PCBlbmRsOwogICAgICAgIG4rKzsKICAgICAgICAKICAgfQogICBjb3V0PDx0bjsKICAgLy9jaW4uaWdub3JlKCk7CiAgIC8vY2luLmdldCgpOwogICByZXR1cm4gMDsKfQ==