NGM - A Game with Numbers

Nikifor and Trofim play the following game: they write some positive integer smaller than 2,000,000,000 and take turns one after another. Nikifor is the first to make a move. The turn is made by the following rule: from the written integer any non-zero digit is subtracted, and the new integer replaces the old one on the desk. For example for integer 40534, the next move can be: 40530, 40531 or 40529. The winner is the player who writes zero on the desk.

Write a program to decide who will win if both players do their best.

Input

The input contains the positive integer from which the game is started.

Output

In the first line you must write 1 if Nikifor wins and 2 otherwise. If Nikifor wins then in the second line you must output the move in the first turn which guarantees victory for him. If there are many such moves then output any of them.

Example

Input:
14

Output:
1
4

Author: Filimonenkov D.O.


Added by:Roman Sol
Date:2006-05-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:ZCon 2007

hide comments
2015-07-26 14:17:29 Ravi
Two Wrong answer for silly mistake
was printing 0 instead of 2 :@
2015-07-17 18:22:32 Aditya
digit which user can subtract from Integer can only be digit from integer ?
2015-06-29 09:11:15 Shantanu Banerjee
Tuffest Problem Ever! LOL! :D
2015-06-13 17:54:38 radhika
hope you get it

Last edit: 2015-06-13 17:55:15
2015-06-13 17:54:22 radhika
you need to mention the starting number the very first which gurantees victory i.e 4
2015-06-07 23:59:43 Addy
Shortest code ever! :)
2015-06-04 14:11:57 Manish Sombansh
smallest piece of code I've written in a long time!
2015-05-18 18:32:02 ATUL GUPTA
I'm just one of the spoiling idiots here

Last edit: 2021-06-05 22:17:38
2015-05-07 17:35:57 scyth3r
for every input....try to make Nikifor as winner
2015-03-28 12:10:35
I may only be able to solve 1 problems aside of this one, but why not try and spoil it for everyone else just to conclusively prove my stupidity.

Last edit: 2021-06-05 22:18:56
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.