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

#SP0000129. Thuế thu nhập (Taxes)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Thuế thu nhập (Taxes)

Taxes

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A person has total income nn burles. The tax on an amount x≥2x\ge2 equals the largest positive proper divisor of xx. For instance, the tax is 33 for 66, 55 for 2525, and 11 for 22.

The person may split nn into any positive number of parts n1+⋯+nk=nn_1+\cdots+n_k=n, with each ni≥2n_i\ge2. Each part is taxed separately. Find the minimum possible sum of taxes.

Input

One line containing the integer nn.

Output

Print one integer: the minimum total tax.

Subtasks

  • Subtask 1 (20 points): 2≤n≤1002\le n\le 100.
  • Subtask 2 (30 points): 2≤n≤1000002\le n\le 100000.
  • Subtask 3 (50 points): 2≤n≤20000000002\le n\le 2000000000.

Examples

Input

27

Output

3

Explanation

For n=27n=27, split it as 2+2+232+2+23. All three parts are prime, so each tax is 11 and the total is 33. A total of 11 is impossible because 2727 is composite, and a total of 22 is impossible because 27−2=2527-2=25 is composite. Thus print 3.