#include <bits/stdc++.h>
using namespace std;
string inp;
long long ans = 0, pw = 1, other = 0;
int main() {
  cin >> inp;
  for (int i = 1; i < inp.size(); i++) {
    pw *= 2;
    ans += pw;
  }
  for (int i = 0; i < inp.size(); i++) {
    if (inp[i] == '7') other |= 1;
    other <<= 1;
  }
  ans += other / 2;
  cout << ans + 1 << endl;
}
