#include <bits/stdc++.h>
const int inf = 1e9 + 7;
const long long int INF = 1e18;
const double pi = 2 * acos(0);
int64_t gcd(int64_t a, int64_t b) { return b == 0 ? a : gcd(b, a % b); }
int64_t lcm(int64_t a, int64_t b) { return a / gcd(a, b) * b; }
int64_t mod_pow(int64_t a, int64_t b, int64_t m) {
  if (b == 0) return 1;
  if (b & 1) return a * mod_pow(a, b - 1, m) % m;
  return mod_pow(a * a % m, b >> 1, m);
}
bool is_prime(int64_t x) {
  if (x <= 3) return x >= 2;
  if (x % 2 == 0) return false;
  for (int64_t d = 3; d * d <= x; d += 2) {
    if (x % d == 0) return false;
  }
  return true;
}
long long int n;
long long int f(long long int i) {
  if (i > n) return 0;
  if (i == n) return 1;
  long long int ans = 1;
  ans += f(i * 10 + 7);
  ans += f(i * 10 + 4);
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::cin >> n;
  std::cout << f(4) + f(7);
}

### Prompt

Please provide a CPP coded solution to the problem described below:

Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."

<image>

The problem is: 

You are given a lucky number n. Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

If we sort all lucky numbers in increasing order, what's the 1-based index of n? 

Tavas is not as smart as SaDDas, so he asked you to do him a favor and solve this problem so he can have his headphones back.

Input

The first and only line of input contains a lucky number n (1 ≤ n ≤ 109).

Output

Print the index of n among all lucky numbers.

Examples

Input

4


Output

1


Input

7


Output

2


Input

77


Output

6

### Response

```cpp
#include <bits/stdc++.h>
const int inf = 1e9 + 7;
const long long int INF = 1e18;
const double pi = 2 * acos(0);
int64_t gcd(int64_t a, int64_t b) { return b == 0 ? a : gcd(b, a % b); }
int64_t lcm(int64_t a, int64_t b) { return a / gcd(a, b) * b; }
int64_t mod_pow(int64_t a, int64_t b, int64_t m) {
  if (b == 0) return 1;
  if (b & 1) return a * mod_pow(a, b - 1, m) % m;
  return mod_pow(a * a % m, b >> 1, m);
}
bool is_prime(int64_t x) {
  if (x <= 3) return x >= 2;
  if (x % 2 == 0) return false;
  for (int64_t d = 3; d * d <= x; d += 2) {
    if (x % d == 0) return false;
  }
  return true;
}
long long int n;
long long int f(long long int i) {
  if (i > n) return 0;
  if (i == n) return 1;
  long long int ans = 1;
  ans += f(i * 10 + 7);
  ans += f(i * 10 + 4);
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::cin >> n;
  std::cout << f(4) + f(7);
}

```