#include <bits/stdc++.h>
using namespace std;
bool SortbySecDesc(const pair<long long, long long> &a,
                   const pair<long long, long long> &b) {
  return a.second > b.second;
}
bool SortbySecInc(const pair<long long, long long> &a,
                  const pair<long long, long long> &b) {
  return a.second < b.second;
}
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
struct compare {
  bool operator()(const pair<int, int> &value, const int &key) {
    return (value.first < key);
  }
  bool operator()(const int &key, const pair<int, int> &value) {
    return (key < value.first);
  }
};
int String_to_int(string s) {
  stringstream geek(s);
  int ans = 0;
  geek >> ans;
  return ans;
}
int S_I(string s) { return stoi(s); }
vector<long long> v;
void kor(long long num) {
  v.push_back(num);
  if (num > 1000000000) {
    return;
  }
  kor(10 * num + 4);
  kor(10 * num + 7);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  ;
  kor(0);
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  long long n;
  cin >> n;
  cout << lower_bound(v.begin(), v.end(), n) - v.begin() << "\n";
  ;
  return 0;
}
