#include <bits/stdc++.h>
using namespace std;
long long expo(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  if (b == 2) return a * a;
  if (b % 2 == 0) {
    return expo(expo(a, b / 2), 2);
  } else {
    return a * (expo(expo(a, (b - 1) / 2), 2));
  }
}
int main() {
  long long n, i, x, r, y, k, d, l, z, b, ans = 0, c = 0, sum = 0;
  cin >> n;
  r = n;
  while (r != 0) {
    c++;
    r /= 10;
  }
  b = 2;
  for (i = 1; i < c; i++) {
    sum += b;
    b *= 2;
  }
  x = n;
  y = expo(2, c);
  d = expo(10, c - 1);
  while (x != 0) {
    k = x / d;
    if (k == 7) {
      sum += y / 2;
    }
    x = x - k * d;
    d /= 10;
    y = y / 2;
  }
  cout << sum + 1 << endl;
  return 0;
}
