Today is the sequence day! The math teacher wrote some sequences on the whiteboard, each having different numbers, all from to , and told the students that these sequences had some special property. After some careful consideration, one of the students, Deni, guessed the correct property. All the sequences on the whiteboard had at least one pair of adjacent numbers in the form . Deni was so happy that she called this type of sequence pretty. For example, for the sequences: and are pretty but the sequences and aren't. After that, the math teacher gave Deni a harder question. She was asked to calculate the number of all possible pretty sequences with different numbers, all from to . This was so hard that Deni couldn't find an answer during the whole class. You are a friend of Deni and want to help her.
Task
Write a program which for a given has to tell Deni the number of pretty sequences. This number can be rather large, so you have to calculate it modulo .
Input
From the first line of the standard input, read two integers and - the length of the sequences on the whiteboard and the module, used for the calculation.
Output
On one line of the standard output, the program has to write one integer - the number of pretty sequences with different numbers, all from to , modulo .
Constraints
Subtasks
Subtaks 1 (0 points)
- The examples.
Subtask 2 (9 points)
Subtask 3 (14 points)
Subtask 4 (11 points)
Subtask 5 (43 points)
Subtask 6 (23 points)
Examples
stdin
4 42
stdout
13
Explanation
The pretty sequences with different numbers, all from to , are:
1 2 3 4
1 3 4 2
1 4 2 3
2 1 3 4
2 3 1 4
2 3 4 1
3 1 2 4
3 4 2 1
4 1 2 3
4 2 3 1
4 3 1 2
stdin
2000 10009
stdout
1295
Explanation
Here the real answer is a large number whose remainder modulo is .