#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(int a, int b) { return (a / gcd(a, b)) * b; }
bool isprime(long long n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}
long long convertDecimalToBinary(int n) {
  long long binaryNumber = 0;
  int remainder, i = 1, step = 1;
  while (n != 0) {
    remainder = n % 2;
    n /= 2;
    binaryNumber += remainder * i;
    i *= 10;
  }
  return binaryNumber;
}
void mi() {
  char a[20];
  cin >> a;
  long long ans = 0;
  long long di = strlen(a);
  ans = (1 << di) - 2;
  for (int i = di - 1, count = 0; i >= 0; i--, count++) {
    if (a[i] == '7') {
      ans += (1 << count);
    }
  }
  cout << ans + 1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long t = 1;
  while (t--) mi();
}
