#include <bits/stdc++.h>
using namespace std;
void Transpose(long long **arr, long long n) {
  for (long long i = 0; i < n; i++)
    for (long long j = 1; j < n; j++) swap(arr[i][j], arr[j][i]);
}
int main() {
  string str;
  cin >> str;
  long long dig = str.length();
  long long res = (1 << str.length()) - 2;
  for (long long i = dig - 1, c = 0; i >= 0; i--, c++) {
    if (str[i] == '7') res += (1 << c);
  }
  cout << res + 1 << endl;
  return 0;
}
