Unique Paths

MediumDynamic Programming
Next
Dynamic ProgrammingMathGrid DP

A robot stands in the top-left corner of an m x n grid and wants to reach the bottom-right corner. It can only move right or down. How many different paths are there?

Input

A single line with m and n.

Output

Print the number of unique paths.

Constraints

1 <= m, n <= 18

Example 1
Input
3 7
Output
28

There are 28 distinct paths.

Example 2
Input
3 2
Output
3

Three paths: RDD, DRD, DDR.

Hints

Unique Paths - Medium Dynamic Programming Problem | Skill Shiksha