#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> holder;
void Lucky(long long num, int i) {
  if (i == 10) {
    if (num) {
      holder.push_back(num);
    }
    return;
  }
  Lucky(num * 10 + 4, i + 1);
  Lucky(num * 10 + 7, i + 1);
  Lucky(num, i + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  Lucky(0, 1);
  holder.push_back(4444444444);
  sort(((holder).begin()), ((holder).end()));
  holder.erase(unique(((holder).begin()), ((holder).end())), holder.end());
  cout << (upper_bound(((holder).begin()), ((holder).end()), n) -
           holder.begin())
       << endl;
}
