PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000319. Chữ số 3 kỳ diệu (The Magical 3)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chữ số 3 kỳ diệu (The Magical 3)

The Magical 3

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

A positive integer nn may be represented in different integer bases bb. In any base b≥4b\ge4, digit 33 is a valid digit.

Find the smallest integer base b≥4b\ge4 such that the final (least significant) digit of the representation of nn in base bb is 33. If no such base exists, print the prescribed failure message.

For example, 11=1⋅8+311=1\cdot8+3 has last digit 33 in base 88, but 11=2⋅4+311=2\cdot4+3, so base 44 is the minimum.

Input

One line contains the positive integer nn.

Output

Print the smallest suitable base bb. If no suitable base exists, print exactly No such base.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1001\le n\le100.
  • Subtask 2 (30 points): 1≤n≤1000001\le n\le100000.
  • Subtask 3 (50 points): 1≤n<2311\le n<2^{31}.

Examples

Example 1

Input

11

Output

4

Explanation

Because 11 mod 4=311\bmod4=3, the smallest permitted base, 44, already works.

Example 2

Input

42

Output

13

Explanation

We have 42−3=39=3⋅1342-3=39=3\cdot13. Its divisors are 1,3,13,391,3,13,39, and the smallest one at least 44 is 1313.

Example 3

Input

2

Output

No such base

Explanation

In any base b≥4b\ge4, the single digit of the number 22 is 22, not 33.

Example 4

Input

3

Output

4

Explanation

The number 33 is represented by the single digit 33 in every base b≥4b\ge4, so the minimum is 44.