#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7, MAX = 1e18;
vector<long long> prim;
long long power(long long n) {
  long long ans = 1;
  for (long long i = 0; i < n; i++) {
    ans = ans * 2;
  }
  return ans;
}
long long isprime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return i;
    }
  }
  return 0;
}
long long fact(long long n) {
  long long ans = 1;
  for (long long i = 2; i <= n; i++) {
    ans = ans * i;
  }
  return ans;
}
void SoE(long long n) {
  prim.clear();
  for (long long i = 2; i <= n; i++) {
    if (isprime(i) == 0) {
      prim.push_back(i);
    }
  }
}
long long gc(long long a, long long b) {
  if (a == 0) {
    return b;
  }
  if (b == 0) return a;
  if (a == b) return a;
  if (a > b) return gc(a - b, b);
  return gc(a, b - a);
}
long long bis(vector<long long> a, long long n, long long k) {
  long long low = 0, high = n - 1, mid;
  long long ans = 0;
  while (low <= high) {
    mid = (low + high) / 2;
    if (k < a[mid]) {
      high = mid - 1;
    } else if (k > a[mid]) {
      low = mid + 1;
    } else {
      ans = 1;
      break;
    }
  }
  if (ans == 1) {
    return mid;
  } else {
    return -1;
  }
}
class pehli {
 public:
  long long name;
  vector<long long> a;
} pehli;
long long fun(long long n) {
  long long ans = 0;
  while (n > 0) {
    long long l = n % 2;
    if (l == 1) ans++;
    n = n / 2;
  }
  return ans;
}
long long dTB(long long N) {
  long long B_Num = 0;
  int cn = 0;
  while (N != 0) {
    int r = N % 2;
    long long c = pow(10, cn);
    B_Num += r * c;
    N /= 2;
    cn++;
  }
  return B_Num;
}
string BTD(long long n) {
  long long m = n;
  string k = "";
  while (m > 0) {
    if (m % 10 == 0) {
      k = k + '1';
    } else {
      k = k + '0';
    }
    m = m / 10;
  }
  reverse(k.begin(), k.end());
  return k;
}
long long binToDec(string second) {
  bitset<64> bits(second);
  long long number = bits.to_ulong();
  return number;
}
long long middle(long long a, long long b) {
  if ((a + b) % 2 == 0)
    return (a + b) / 2;
  else
    return -1;
}
bool che(long long a, long long b, long long c) {
  if (a + b == 2 * c) {
    return true;
  } else if (a + c == 2 * b) {
    return true;
  } else if (b + c == 2 * a) {
    return true;
  } else {
    return false;
  }
}
long long mi = MAX;
vector<long long> adj[200001];
vector<long long> a(100001);
bool visited[100001] = {false};
void add_Edge(int u, int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
void remove_edge(int u, int v) {}
void dfs(long long n) {
  visited[n] = true;
  for (auto i : adj[n]) {
    if (visited[i] == false) {
      dfs(i);
    }
  }
}
string change(string u) {
  for (long long i = 0; i < u.length(); i++) {
    u[i] = 1 - (u[i] - '0');
  }
  return u;
}
bool ch(vector<long long> a) {
  long long sum = 0;
  for (long long i = 0; i < a.size(); i++) {
    sum = sum + a[i];
    if (sum < 0) return false;
  }
  if (sum == 0)
    return true;
  else
    return false;
}
bool sortbysec(const pair<int, pair<long long, long long> > &a,
               const pair<int, pair<long long, long long> > &b) {
  return a.second.first < b.second.first;
}
bool sortbysecdesc(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second > b.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  {
    vector<long long> a, b;
    map<long long, long long> make_pair, mp1;
    string blank;
    long long ans = 0, n, l = 0, k = 0, sum = 0, j = 0, m = 0, ans1 = 0,
              ans2 = 0, r = 0, sum1 = 0, sum2 = 0;
    cin >> n;
    long long n1 = n;
    string second = "";
    while (n1 > 0) {
      l++;
      k = n1 % 10;
      if (k == 4)
        second = second + '0';
      else
        second = second + '1';
      n1 = n1 / 10;
    }
    for (int i = 0; i < second.size(); i++) {
      if (second[i] == '1') {
        ans1 = ans1 + pow(2, i);
      }
    }
    for (long long i = 1; i <= l - 1; i++) {
      ans = ans + pow(2, i);
    }
    ans = ans + ans1 + 1;
    cout << ans;
  }
  return 0;
}
