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

#GL0000267. Độ sâu của hàm phi Euler (Euler Totient Function Depth)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Độ sâu của hàm phi Euler (Euler Totient Function Depth)

Euler Totient Function Depth

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

For a positive integer xx, define a0=xa_0=x and at+1=φ(at)a_{t+1}=\varphi(a_t). The depth of xx is the minimum number of iterations required to reach 11, so the depth of 11 is 00. Given an interval [m,n][m,n] and an integer kk, count integers with depth exactly kk.

Input

One line containing integers m,n,km,n,k in that order.

Output

Print the number of integers in [m,n][m,n] having depth kk.

Subtasks

  • Subtask 1 (20 points): 1≤m≤n≤1001\le m\le n\le 100; 0≤k<200\le k<20.
  • Subtask 2 (30 points): 1≤m≤n≤100001\le m\le n\le 10000; 0≤k<200\le k<20.
  • Subtask 3 (50 points): 1≤m≤n≤10000001\le m\le n\le 1000000; 0≤k<200\le k<20.

Examples

Example 1

Input

1 3 1

Output

1

Explanation

We inspect [1,3][1,3] for depth 11. Exactly 1 integers qualify. In particular, 11 has depth 00, while 5→4→2→15\to4\to2\to1 gives depth 33.

Example 2

Input

1 10 2

Output

3

Explanation

We inspect [1,10][1,10] for depth 22. Exactly 3 integers qualify. In particular, 11 has depth 00, while 5→4→2→15\to4\to2\to1 gives depth 33.

Example 3

Input

1 10 3

Output

5

Explanation

We inspect [1,10][1,10] for depth 33. Exactly 5 integers qualify. In particular, 11 has depth 00, while 5→4→2→15\to4\to2\to1 gives depth 33.

Example 4

Input

1 100 3

Output

8

Explanation

We inspect [1,100][1,100] for depth 33. Exactly 8 integers qualify. In particular, 11 has depth 00, while 5→4→2→15\to4\to2\to1 gives depth 33.