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

#GL0000204. Chữ số cuối khác 0 của BCNN từ 1 đến N (LCM)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Chữ số cuối khác 0 của BCNN từ 1 đến N (LCM)

Chữ số cuối khác 0 của BCNN từ 1 đến N (LCM)

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Let LN=lcm⁡(1,2,…,N)L_N=\operatorname{lcm}(1,2,\ldots,N). Determine the last nonzero decimal digit of LNL_N, without constructing this very large integer. For instance, L6=60L_6=60 has last nonzero digit 66.

Input

A single positive integer NN.

Output

Print one digit from 11 to 99.

Subtasks

  • Subtask 1 (20 points): 1≤N≤1001\le N\le 100.

  • Subtask 2 (30 points): 1≤N≤100001\le N\le 10000.

  • Subtask 3 (50 points): 1≤N≤10000001\le N\le 1000000.

Examples

Example 1

Input

3

Output

6

Explanation

LCM(1,2,3)=6.

Example 2

Input

5

Output

6

Explanation

LCM(1,...,5)=60; its last nonzero digit is 6.

Example 3

Input

10

Output

2

Explanation

LCM(1,...,10)=2520; its last nonzero digit is 2.