cswork / OAOpen practice workspace

SnowflakeOA #1

Prime String — Count Ways to Split into Primes

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.

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. All examples have been verified by independent small-scale enumeration or state search.

Editorial

Loading solution…