#P6189. Counting Non-Increasing Running Plans

    ID: 19409 Type: Default 1000ms 256MiB

Counting Non-Increasing Running Plans

Counting Non-Increasing Running Plans

Little H loves sports. One day, he decided to create a running plan. He plans to run a total of \(n\) meters. During the \(i\)th minute (\(i \ge 1\)), he will run \(x_i\) meters (where \(x_i\) is a positive integer), but he has not decided on the total duration of the run.

Since Little H gets more tired as he runs longer, his plan must satisfy the condition that for any \(i > 1\), \(x_i \le x_{i-1}\). In other words, the distances run per minute form a non-increasing sequence.

Your task is to determine how many different running plans satisfy these conditions. Two plans are considered different if they have different total durations or if there exists an index \(i\) such that the \(i\)th minute distances are different.

Since the final answer can be very large, output the result modulo \(p\).

inputFormat

The input consists of a single line containing two integers \(n\) and \(p\) (separated by a space), where \(n\) is the total distance to run and \(p\) is the modulus.

outputFormat

Output a single integer: the number of valid running plans modulo \(p\).

sample

4 1000
5

</p>