cswork / OAOpen practice workspace

SnowflakeOA #22

Prime String

Estimated MediumJudge-ready

Topics (AI-labelled)DP BasicsBits & Math

Split the entire digit string, keeping its original order, into several primes, where each segment has no leading zeros and each prime lies in 2..10⁶; count the number of ways modulo 10⁹+7. The upper bound 10⁶ is restored from the original snapshot, not the 10⁸ mistakenly written in the catalog. This catalog entry shares its source with an earlier problem; it keeps its own problem ID and is verified independently.

Input

One line containing a digit string of length 1..100000 whose first digit is not 0.

Output

Output the single integer required by the problem.

Example 1

Input:

11375

Output:

3

Example 2

Input:

2

Output:

1

Example 3

Input:

101

Output:

1

Example notes

The answers to the three public examples are, in order: 3; 1; 1. The examples were rechecked by independent enumeration, state search, or direct simulation.

Editorial

Loading solution…