Tavas and SaDDas

题意翻译

## 题目背景 Tavas又在喝没有水的咖啡了。SaDDas为了阻止他这样做,偷走了他的耳机。后来,SaDDas过意不去,于是对Tavas说:我给你出一道题,如果你答对了就把耳机还给你。 ## 题面 如果一个数在十进制下只包含4和7,那么这个数就被称为幸运数字。例如:4、7、47、77、474是幸运数字,而46、27、256则不是幸运数字。现在给你一个数n,要求你输出n是从1开始数第几个幸运数字。(其实也可以理解为从1到n共有几个幸运数字) ## 输入 一个正整数n。 ## 输出 从1到n中幸运数字的个数。 ## 提示 对于第一个样例,从1到4,只有4是幸运数字,4是第一个,所以输出1; 对于第二个样例,从1到7,有4、7是幸运数字,7是第2个,所以输出2; 对于第三个样例,从1到77,有4、7、44、47、74、77是幸运数字,77是第6个,所以输出6.

题目描述

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." ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF535B/f91fa10ac839dabd2f33826f1fa403b926bbc6c1.png)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.

输入输出格式

输入格式


The first and only line of input contains a lucky number $ n $ ( $ 1<=n<=10^{9} $ ).

输出格式


Print the index of $ n $ among all lucky numbers.

输入输出样例

输入样例 #1

4

输出样例 #1

1

输入样例 #2

7

输出样例 #2

2

输入样例 #3

77

输出样例 #3

6