#include <bits/stdc++.h>
using namespace std;
long long n;
const int maxn = 100000 + 10;
vector<int> v;
int main() {
  for (int i = 4; i <= 7; i++)
    if (i == 4 or i == 7) v.push_back(i);
  for (int i = 40; i <= 77; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 10 == 4 or i / 10 == 7))
      v.push_back(i);
  for (int i = 400; i <= 777; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 100 == 4 or i / 100 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4))
      v.push_back(i);
  for (int i = 4000; i <= 7777; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 1000 == 4 or i / 1000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7))
      v.push_back(i);
  for (int i = 40000; i <= 77777; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 10000 == 4 or i / 10000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4))
      v.push_back(i);
  for (int i = 400000; i <= 777777; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 100000 == 4 or i / 100000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4) &&
        (((i % 100000 - i % 10000) / 10000) == 7 or
         ((i % 100000 - i % 10000) / 10000) == 4))
      v.push_back(i);
  for (int i = 4000000; i <= 7777777; i++)
    if ((i % 10 == 4 or i % 10 == 7) &&
        (i / 1000000 == 4 or i / 1000000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4) &&
        (((i % 100000 - i % 10000) / 10000) == 7 or
         ((i % 100000 - i % 10000) / 10000) == 4) &&
        ((i % 1000000 - i % 100000) / 100000 == 7 or
         (i % 1000000 - i % 100000) / 100000 == 4))
      v.push_back(i);
  for (int i = 40000000; i <= 77777777; i++)
    if ((i % 10 == 4 or i % 10 == 7) &&
        (i / 10000000 == 4 or i / 10000000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4) &&
        (((i % 100000 - i % 10000) / 10000) == 7 or
         ((i % 100000 - i % 10000) / 10000) == 4) &&
        ((i % 1000000 - i % 100000) / 100000 == 7 or
         (i % 1000000 - i % 100000) / 100000 == 4) &&
        ((i % 10000000 - i % 1000000) / 1000000 == 7 or
         (i % 10000000 - i % 1000000) / 1000000 == 4) &&
        ((i % 100000000 - i % 10000000) / 10000000 == 4 or
         (i % 100000000 - i % 10000000) / 10000000 == 7))
      v.push_back(i);
  for (int i = 400000000; i <= 777777777; i++)
    if ((i % 10 == 4 or i % 10 == 7) &&
        (i / 100000000 == 4 or i / 100000000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4) &&
        (((i % 100000 - i % 10000) / 10000) == 7 or
         ((i % 100000 - i % 10000) / 10000) == 4) &&
        ((i % 1000000 - i % 100000) / 100000 == 7 or
         (i % 1000000 - i % 100000) / 100000 == 4) &&
        ((i % 10000000 - i % 1000000) / 1000000 == 7 or
         (i % 10000000 - i % 1000000) / 1000000 == 4) &&
        ((i % 100000000 - i % 10000000) / 10000000 == 4 or
         (i % 100000000 - i % 10000000) / 10000000 == 7) &&
        ((i % 1000000000 - i % 100000000) / 100000000 == 4 or
         (i % 1000000000 - i % 100000000) / 100000000 == 7))
      v.push_back(i);
  cin >> n;
  for (int i = 0; i < v.size(); i++)
    if (v[i] == n) {
      cout << i + 1 << endl;
      return 0;
    }
  return 0;
}

### 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>
using namespace std;
long long n;
const int maxn = 100000 + 10;
vector<int> v;
int main() {
  for (int i = 4; i <= 7; i++)
    if (i == 4 or i == 7) v.push_back(i);
  for (int i = 40; i <= 77; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 10 == 4 or i / 10 == 7))
      v.push_back(i);
  for (int i = 400; i <= 777; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 100 == 4 or i / 100 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4))
      v.push_back(i);
  for (int i = 4000; i <= 7777; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 1000 == 4 or i / 1000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7))
      v.push_back(i);
  for (int i = 40000; i <= 77777; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 10000 == 4 or i / 10000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4))
      v.push_back(i);
  for (int i = 400000; i <= 777777; i++)
    if ((i % 10 == 4 or i % 10 == 7) && (i / 100000 == 4 or i / 100000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4) &&
        (((i % 100000 - i % 10000) / 10000) == 7 or
         ((i % 100000 - i % 10000) / 10000) == 4))
      v.push_back(i);
  for (int i = 4000000; i <= 7777777; i++)
    if ((i % 10 == 4 or i % 10 == 7) &&
        (i / 1000000 == 4 or i / 1000000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4) &&
        (((i % 100000 - i % 10000) / 10000) == 7 or
         ((i % 100000 - i % 10000) / 10000) == 4) &&
        ((i % 1000000 - i % 100000) / 100000 == 7 or
         (i % 1000000 - i % 100000) / 100000 == 4))
      v.push_back(i);
  for (int i = 40000000; i <= 77777777; i++)
    if ((i % 10 == 4 or i % 10 == 7) &&
        (i / 10000000 == 4 or i / 10000000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4) &&
        (((i % 100000 - i % 10000) / 10000) == 7 or
         ((i % 100000 - i % 10000) / 10000) == 4) &&
        ((i % 1000000 - i % 100000) / 100000 == 7 or
         (i % 1000000 - i % 100000) / 100000 == 4) &&
        ((i % 10000000 - i % 1000000) / 1000000 == 7 or
         (i % 10000000 - i % 1000000) / 1000000 == 4) &&
        ((i % 100000000 - i % 10000000) / 10000000 == 4 or
         (i % 100000000 - i % 10000000) / 10000000 == 7))
      v.push_back(i);
  for (int i = 400000000; i <= 777777777; i++)
    if ((i % 10 == 4 or i % 10 == 7) &&
        (i / 100000000 == 4 or i / 100000000 == 7) &&
        (((i % 100 - i % 10) / 10) == 7 or ((i % 100 - i % 10) / 10) == 4) &&
        (((i % 1000 - i % 100) / 100) == 4 or
         ((i % 1000 - i % 100) / 100) == 7) &&
        (((i % 10000 - i % 1000) / 1000) == 7 or
         ((i % 10000 - i % 1000) / 1000) == 4) &&
        (((i % 100000 - i % 10000) / 10000) == 7 or
         ((i % 100000 - i % 10000) / 10000) == 4) &&
        ((i % 1000000 - i % 100000) / 100000 == 7 or
         (i % 1000000 - i % 100000) / 100000 == 4) &&
        ((i % 10000000 - i % 1000000) / 1000000 == 7 or
         (i % 10000000 - i % 1000000) / 1000000 == 4) &&
        ((i % 100000000 - i % 10000000) / 10000000 == 4 or
         (i % 100000000 - i % 10000000) / 10000000 == 7) &&
        ((i % 1000000000 - i % 100000000) / 100000000 == 4 or
         (i % 1000000000 - i % 100000000) / 100000000 == 7))
      v.push_back(i);
  cin >> n;
  for (int i = 0; i < v.size(); i++)
    if (v[i] == n) {
      cout << i + 1 << endl;
      return 0;
    }
  return 0;
}

```