#include <bits/stdc++.h>
using namespace std;
char c1, c2;
int mid1, mid2, low1, low2, high1, high2;
int sz;
int reverse(int n) {
  int temp = 0;
  while (n) {
    temp += n % 10;
    temp *= 10;
    n /= 10;
  }
  return temp / 10;
}
int main() {
  int n;
  cin >> n;
  n = reverse(n);
  int ans = 0;
  while (n) {
    ans = ans << 1;
    if (n % 10 == 7)
      ans += 2;
    else {
      ans += 1;
    }
    n /= 10;
  }
  cout << ans;
  return 0;
}
