Make it Happy
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Today everyone is celebrating Happy Numbers Day!
To celebrate, Marichka and Zenyk came up with a new game. Marichka names a number \(a\), and Zenyk has to find the smallest non-negative number \(b\) such that the sum \(a + b\) consists only of the digits 4 and 7.
Zenyk thought this game was very simple, so he figured he could write a program to find the corresponding \(b\) for him. And he asked you to write this program. Help him with his request.
Input
The single line contains a single integer \(a\) – the number named by Marichka.
Output
In the single line, output a single number – the smallest non-negative number \(b\) such that the sum \(a + b\) consists only of the digits 4 and 7.
Constraints
\(0 \le a \le 10^5\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 5 | 2 |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|