#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int a[20];
  long long int b[20];
  long long int i, j;
  for (i = 0; i <= 10; i++) {
    a[i] = pow(2, i);
  }
  b[0] = 0;
  b[1] = a[1];
  for (i = 2; i <= 10; i++) {
    b[i] = b[i - 1] + a[i];
  }
  long long int c, s;
  c = 0;
  s = 0;
  long long int x = n;
  long long int d;
  while (x != 0) {
    d = x % 10;
    x = x / 10;
    c++;
    s = s * 10 + d;
  }
  long long int p = c;
  long long int ans = b[c - 1];
  while (c > 0) {
    d = s % 10;
    if (d == 7) ans += (a[c] / 2);
    s = s / 10;
    c--;
  }
  cout << ans + 1 << endl;
}
