ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

Tetrahedron Team Programming Contest May 2001

About     Problems     Submit solution     Judge status     Standings
Contest is over

E. Don’t Ask Woman about Her Age

Time limit: 1.0 second
Memory limit: 64 MB
Mrs Little likes digits most of all. Every year she tries to make the best number of the year. She tries to become more and more intelligent and every year studies a new digit. And the number she makes is written in numeric system which base equals to her age. To make her life more beautiful she writes only numbers that are divisible by her age minus one. Mrs Little wants to hold her age in secret.
You are given a number consisting of digits 0, …, 9 and Latin letters A, …, Z, where A equals 10, B equals 11 etc. Your task is to find the minimal number k satisfying the following condition: the given number, written in k-based system is divisible by k−1.


Input consists of one string containing no more than 106 digits or uppercase Latin letters.


Output the only number k, or "No solution." if for all 2 ≤ k ≤ 36 condition written above can't be satisfied. By the way, you should write your answer in decimal system.


Problem Author: Igor Goldberg
Problem Source: Tetrahedron Team Contest May 2001
To submit the solution for this problem go to the Problem set: 1104. Don’t Ask Woman about Her Age