#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, ans = 0, dig = 0, pos;
  scanf("%lld", &n);
  ;
  m = n;
  long long pw[12] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};
  while (m > 0) {
    dig++;
    m /= 10;
  }
  ans = pw[dig] - 1;
  m = n;
  pos = 0;
  while (m > 0) {
    if (m % 10 == 7) ans += pw[pos];
    pos++;
    m /= 10;
  }
  printf("%lld\n", ans);
  return 0;
}
