Auxiliary Project
Time limit3sMemory limit512 MB
Choose any multiset of digits whose total lit segments equals n, and maximize the sum of the digits.
Problem
Anna has just finished her course project. She has many leftover seven-segment LED displays and one small power source. A display draws power in proportion to the number of lit segments, so a 9 draws twice as much power as a 7.

One display shows one digit from 0 to 9, and the number of segments each digit lights is fixed.
Anna may use as many displays as she likes, and she wants exactly segments lit in total. Find the largest possible sum of the digits she displays.
Input
The only line contains one integer , the number of segments that must be lit. ()
Output
Print one integer, the largest possible sum of digits displayed at the same time.
Note
For a single 4 is displayed. A 7 is worth more but lights only three segments, so the fourth segment would go unused. For the displays show 4 and 7, and for they show two 7s.