#include <bits/stdc++.h>
using namespace std;
vector<long long> num, t[10];
void gen(int a = 2) {
  if (a > 9) return;
  for (auto x : t[a - 1])
    t[a].push_back(x * 10 + 4), t[a].push_back(x * 10 + 7);
  gen(a + 1);
  return;
}
int main() {
  int n;
  cin >> n;
  t[1].push_back(4);
  t[1].push_back(7);
  gen();
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < t[i].size(); j++) num.push_back(t[i][j]);
  for (int i = 0; i < num.size(); i++)
    if (num[i] == n) return cout << i + 1, 0;
  cout << num.size();
  return 0;
}
