#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int len = 0;
int ans = 0;
while (n) {
if (n % 10 == 7)
ans += (1 << len);
n /= 10;
len++;
}
for (int i = 1; i < len; i++)
ans += (1 << i);
cout << ans + 1 << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJaW50IG47CgljaW4gPj4gbjsKCWludCBsZW4gPSAwOwoJaW50IGFucyA9IDA7Cgl3aGlsZSAobikgewoJCWlmIChuICUgMTAgPT0gNykKCQkJYW5zICs9ICgxIDw8IGxlbik7CgkJbiAvPSAxMDsKCQlsZW4rKzsKCX0KCWZvciAoaW50IGkgPSAxOyBpIDwgbGVuOyBpKyspCgkJYW5zICs9ICgxIDw8IGkpOwoJY291dCA8PCBhbnMgKyAxIDw8IGVuZGw7CglyZXR1cm4gMDsKfQ==