cho.sh
Notes
Loading...

Largest Lucky Number

Time limit

2s

Memory limit

256 MB

Problem

A lucky number is a positive integer whose decimal representation consists only of the digits 4 and 7.

Given a natural number N, find the largest lucky number that is less than or equal to N.

Input

The first line contains a natural number N. N is at least 4 and at most 1,000,000.

Output

Print the largest lucky number that is less than or equal to N.