#include <iostream>#include <string>using namespace std;string st;void work(){ int i, l = st.length(), temp = 1, ans = 0; for (i = l - 1; i >= 0; i--) { temp *= 2; ans += (st[i] - '0') * (temp - 1); } cout << ans << endl;}int main(){ while (getline(cin, st) && st != "0") work(); return 0;}


