#include <bits/stdc++.h>
using namespace std;
double pi = acos(-1);
const long long MOD = 1000000007;
void OJ() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
}
int main() {
  OJ();
  clock_t clk = clock();
  string s;
  cin >> s;
  long long len = s.length(), ans = 0, pos = 0;
  ans += (1 << len) - 2;
  for (long long i = len - 1; i >= 0; i--) {
    if (s[i] == '7') ans += (1 << pos);
    pos++;
  }
  cout << ans + 1;
  clk = clock() - clk;
  cerr << "Time Elapsed: " << fixed << setprecision(10)
       << ((long double)clk) / CLOCKS_PER_SEC << "\n";
}
