#include <bits/stdc++.h>
using namespace std;
int main() {
  int in, x = 0;
  int cnt = 0, p = 1, ans = 0;
  cin >> in;
  for (int i = in; i > 0; i /= 10) {
    if (i % 10 == 7) ans += p;
    p *= 2;
    cnt++;
  }
  if (cnt != 0) x = pow(2, cnt) - 2;
  cout << ans + x + 1;
}
