Correct expressions

In this problem we consider the expressions defined as follows:

For instance, if the set of variables is A,B,C{A, B, C}, these are some correct expressions:

A(A)((C))(A)(B)((A)(B))(A)A \qquad (A) \qquad ((C)) \qquad (A)-(B) \qquad ((A)-(B))-(A)

Write a program that, given two numbers nn and mm, prints the number of correct expressions of length exactly nn that can be made up with mm variables.

For instance, for n=7n =7 and m=2m=2 the result should be 6, corresponding to

(((A)))(((B)))(A)(A)(A)(B)(B)(A)(B)(B)(((A))) \qquad (((B))) \qquad (A)-(A) \qquad (A)-(B) \qquad (B)-(A) \qquad (B)-(B)

Input

Input consists of several cases, each with two natural numbers nn and mm between 11 and 2525.

Output

For every case, print the number of correct expressions of length exactly nn that can be made up with mm variables. This number will always be smaller than 10910^9.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:37:05.828Z

© Jutge.org, 2006–2026.
https://jutge.org