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

#SP0000133. Tổng các số nguyên tố liên tiếp (Sum of Primes)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Tổng các số nguyên tố liên tiếp (Sum of Primes)

Sum of Primes

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Consider the prime numbers in increasing order: 2,3,5,7,11,13,…2,3,5,7,11,13,\ldots. A representation of a positive integer nn is a nonempty contiguous segment of this prime sequence whose sum equals nn.

The selected primes must be consecutive in the prime sequence, not just an arbitrary set of primes. A segment containing one prime is valid.

Count all such segments. Representations with different starting or ending positions are distinct.

Input

One line contains the integer nn.

Output

Print one integer: the number of valid representations of nn.

Subtasks

  • Subtask 1 (20 points): 2≤n≤1002\le n\le 100.
  • Subtask 2 (30 points): 2≤n≤20002\le n\le 2000.
  • Subtask 3 (50 points): 2≤n≤110002\le n\le 11000.

Examples

Input

41

Output

3

Explanation

For n=41n=41, exactly three consecutive-prime segments sum to 4141:

  • 2+3+5+7+11+13=412+3+5+7+11+13=41;
  • 11+13+17=4111+13+17=41;
  • the one-element segment 4141.

For instance, 7+137+13 is invalid because prime 1111 lies between them. Hence the answer is 3.