#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> four, seven;
  four.push_back(4);
  seven.push_back(7);
  long long vff = 4, vfs = 7;
  int i = 0;
  while (i <= 512) {
    vff = four[i] * 10 + 4;
    vfs = seven[i] * 10 + 4;
    if (vff <= 10e9) four.push_back(vff);
    if (vfs <= 10e9) seven.push_back(vfs);
    vff = four[i] * 10 + 7;
    vfs = seven[i] * 10 + 7;
    if (vff <= 10e9) four.push_back(vff);
    if (vfs <= 10e9) seven.push_back(vfs);
    i++;
  }
  vector<long long> ans;
  ans.insert(ans.end(), four.begin(), four.end());
  ans.insert(ans.end(), seven.begin(), seven.end());
  sort(ans.begin(), ans.end());
  int n;
  cin >> n;
  cout << upper_bound(ans.begin(), ans.end(), n) - ans.begin() << endl;
}
