#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;
}