#include <bits/stdc++.h>
using namespace std;
void solve(int n, int i, int &ans) {
  if (n == 0) return;
  int digits = floor(log10(n)) + 1;
  ans += pow(2, digits - 1);
  if (n % 10 == 7) ans += pow(2, i);
  solve(n / 10, ++i, ans);
}
int main() {
  int n;
  cin >> n;
  int digits = floor(log10(n)) + 1;
  int ans = 0;
  solve(n, 0, ans);
  cout << ans;
}
