535B.md (1290B)
1 Source: https://codeforces.com/problemset/problem/535/B 2 3 B. Tavas and SaDDas 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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." 22 23  24 25 The problem is: 26 27 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. 28 29 If we sort all lucky numbers in increasing order, what's the 1-based index of *n*? 30 31 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. 32 33 Input 34 35 The first and only line of input contains a lucky number *n* (1 ≤ *n* ≤ 109). 36 37 Output 38 39 Print the index of *n* among all lucky numbers. 40 41 Examples 42 43 Input 44 45 ``` 46 4 47 ``` 48 49 Output 50 51 ``` 52 1 53 ``` 54 55 Input 56 57 ``` 58 7 59 ``` 60 61 Output 62 63 ``` 64 2 65 ``` 66 67 Input 68 69 ``` 70 77 71 ``` 72 73 Output 74 75 ``` 76 6 77 ```