Progress in Military Technology#345

Progress in Military Technology

1 second
64 megabytes
Medium

Some military units have always made intensive use of various counting devices. Originally, these devices were mechanical and displayed calculations using wheels with digits drawn on them. However, as technology advanced, engineers designed an electrical device that displayed results using segment indicators.

There were no complaints about its speed and accuracy, but its method of display caused concern. One senior officer was particularly distrustful. In his opinion, these indicators were not entirely reliable. If a necessary segment failed to light up, or an unnecessary one did, the result would be distorted. If the distortion resulted in nonsense, the operator would notice. But if the result still looked plausible, like an ordinary sequence of digits, that could be dangerous. For example, a single digit distortion could turn into . Two digit distortions could turn into . Such errors could cause artillery to target the wrong coordinates!

Your task is to develop a program that, given a number, determines the largest possible deviation in its display caused by a "one-segment error" in one or two digits.

Input

The first line contains the non-negative integer that is being checked for possible distortions, 0 \leq N \leq 10^{1000}.

Output

The first line should contain a positive integer equal to the maximum possible deviation from the true value with a one-segment error in a single digit.

The second line should contain the maximum possible deviation with one-segment errors in two different digits.

If it is impossible to have a deviation in any of these cases, output the word NO instead of a number.

Only situations in which the distorted result still appears valid should be considered. It is assumed that the device does not display non-significant leading zeros, so distortions like " is shown as " are not considered.

Examples

Example 1

Loading
Loading