#include <bits/stdc++.h>
long long inv = 301388891;
long long mod = 1000000007;
using namespace std;
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
const int INF = (1 << 30);
long long modpow(int a, long long b, long long m) {
a %= m;
long long r = 1;
while (b > 0) {
if (b & 1) r = (r * 1LL * a) % m;
a = (a * 1LL * a) % m;
b >>= 1;
}
return r;
}
int A[10005];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
A[1] = 4;
A[2] = 7;
int rn = 2, in = 3, pn = 0, sn = 3;
for(int i = 1; i <= 9; ++i){
for(int j = 1; j <= rn; ++j){
A[in] = (4 * pow(10, i)) + A[pn + j];
++in;
}
for(int k = 1; k <= rn; ++k){
A[in] = (7 * pow(10, i)) + A[pn + k];
++in;
}
rn = pow(2, i + 1);
pn += pow(2 , i);
}
int n;
cin>>n;
// for(int i = 1; i <= 1000; ++i)
// cout<<A[i]<<" ";
int loc;
for(int i = 1; i <= 10000; ++i){
if(A[i] == n){
loc = i;
break;
}
}
cout<<loc;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgpsb25nIGxvbmcgaW52ID0gMzAxMzg4ODkxOwpsb25nIGxvbmcgbW9kID0gMTAwMDAwMDAwNzsKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBmcyBmaXJzdAojZGVmaW5lIHNjIHNlY29uZApjb25zdCBpbnQgSU5GID0gKDEgPDwgMzApOwoKbG9uZyBsb25nIG1vZHBvdyhpbnQgYSwgbG9uZyBsb25nIGIsIGxvbmcgbG9uZyBtKSB7CiAgICBhICU9IG07CiAgICBsb25nIGxvbmcgciA9IDE7CiAgICB3aGlsZSAoYiA+IDApIHsKICAgICAgICBpZiAoYiAmIDEpIHIgPSAociAqIDFMTCAqIGEpICUgbTsKICAgICAgICBhID0gKGEgKiAxTEwgKiBhKSAlIG07CiAgICAgICAgYiA+Pj0gMTsKICAgIH0KICAgIHJldHVybiByOwp9CgppbnQgQVsxMDAwNV07CgoKIAppbnQgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOyBjaW4udGllKDApOwogICAgQVsxXSA9IDQ7CiAgICBBWzJdID0gNzsKICAgIGludCBybiA9IDIsIGluID0gMywgcG4gPSAwLCBzbiA9IDM7CiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IDk7ICsraSl7CiAgICAgICAgZm9yKGludCBqID0gMTsgaiA8PSBybjsgKytqKXsKICAgICAgICAgICAgQVtpbl0gPSAoNCAqIHBvdygxMCwgaSkpICsgQVtwbiArIGpdOwogICAgICAgICAgICArK2luOwogICAgICAgIH0KICAgICAgICBmb3IoaW50IGsgPSAgMTsgayA8PSBybjsgKytrKXsKICAgICAgICAgICAgQVtpbl0gPSAoNyAqIHBvdygxMCwgaSkpICsgQVtwbiArIGtdOwogICAgICAgICAgICArK2luOwogICAgICAgIH0KICAgICAgICBybiA9IHBvdygyLCBpICsgMSk7CiAgICAgICAgcG4gKz0gcG93KDIgLCBpKTsKICAgIH0KICAgIGludCBuOwogICAgY2luPj5uOwogICAgLy8gZm9yKGludCBpID0gMTsgaSA8PSAxMDAwOyArK2kpCiAgICAvLyAgY291dDw8QVtpXTw8IiAiOwogICAgaW50IGxvYzsKICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gMTAwMDA7ICsraSl7CiAgICAgICAgaWYoQVtpXSA9PSBuKXsKICAgICAgICAgICAgbG9jID0gaTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgfQogICAgY291dDw8bG9jOwogICAgcmV0dXJuIDA7Cn0=