#P2618. 数字工程

数字工程

Description

The ACM Laboratory has launched a number engineering project, aiming to transform a positive integer nn into 11 using some special methods.

Available methods are:

  1. Subtract 11.
  2. Divide by any one of its prime factors.

Each operation consumes one unit of energy.

What is the minimum energy required to turn nn into 11?

Input Format

This problem contains multiple test cases.

For each test case, there is one line with an integer nn.

Output Format

Output one line with a single integer, the minimum energy consumed.

1
4
0
2

Hint

Constraints: 1n1061 \le n \le 10^6.

Translated by ChatGPT 5