#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<long long> v;
void brute(long long num)
{
v.push_back(num);
if (num > 1000000000)
return;
brute(num * 10 + 4);
brute(num * 10 + 7);
}
int main()
{
ios::sync_with_stdio(false);
brute(0);
sort(v.begin(), v.end());
v.resize(unique(v.begin(), v.end()) - v.begin());
int n;
cin >> n;
cout << lower_bound(v.begin(), v.end(), n) - v.begin() << endl;
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp2ZWN0b3I8bG9uZyBsb25nPiB2Owp2b2lkIGJydXRlKGxvbmcgbG9uZyBudW0pCnsKCXYucHVzaF9iYWNrKG51bSk7CglpZiAobnVtID4gMTAwMDAwMDAwMCkKCQlyZXR1cm47CglicnV0ZShudW0gKiAxMCArIDQpOwoJYnJ1dGUobnVtICogMTAgKyA3KTsKfQppbnQgbWFpbigpCnsKCWlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKCWJydXRlKDApOwoJc29ydCh2LmJlZ2luKCksIHYuZW5kKCkpOwoJdi5yZXNpemUodW5pcXVlKHYuYmVnaW4oKSwgdi5lbmQoKSkgLSB2LmJlZ2luKCkpOwoJaW50IG47CgljaW4gPj4gbjsKCWNvdXQgPDwgbG93ZXJfYm91bmQodi5iZWdpbigpLCB2LmVuZCgpLCBuKSAtIHYuYmVnaW4oKSA8PCBlbmRsOwoJcmV0dXJuIDA7Cn0=