#include <bits/stdc++.h>
using namespace std;
int main() {
  char arr[12];
  cin >> arr;
  int digit = strlen(arr);
  int ans = 0;
  ans = (1 << digit) - 2;
  for (int i = digit - 1; i >= 0; i--) {
    if (arr[i] == '7') ans += 1 << (digit - 1 - i);
  }
  cout << ans + 1;
}
