394. Tavas and SaDDas

0

Medium

Tavas has a peculiar habit of eating coffee mix without water, despite the unpleasant smell. Keione, his friend, decided to teach him a lesson and enlisted the help of SaDDas. SaDDas took Tavas' headphones and challenged him to solve a problem in order to get them back. The problem is as follows: Given a lucky number n, where lucky numbers are positive integers that only contain the digits 4 and 7 in their decimal representation, determine the 1-based index of n when all lucky numbers are sorted in increasing order. Since Tavas is not as skilled as SaDDas, he seeks your assistance in solving this problem and retrieving his headphones.

Input Format

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

Output Format

Print the index of n among all lucky numbers.

Example

Input

4

Output

1

Constraints

Loading...

View Submissions

Console