This page is still under construction.

Parts of this page are still being built. What you see may change.

Lane Direction Signs

Time limit2sMemory limit1024 MB

Summary
Count the assignments of nonempty subsets of m directions to n lanes such that allowed directions are nondecreasing across lanes and every direction appears in some lane.
Level

Medium7 of 10

Topics
Dynamic programming, Combinatorics, Math, Implementation
Solved
No attempts yet

Problem

When organizing traffic at complex intersections, restrictions are placed on the maneuvers drivers may make depending on the lane they used to approach the intersection, so that the paths of drivers performing different maneuvers do not cross. A <> sign is used for this; the figure on the right shows an example of such a sign installed before one of the intersections in Saint Petersburg.

Consider a road leading to an intersection where mm roads meet. A driver approaching the intersection along this road can potentially continue in mm different directions: back along the road they came from, or along one of the remaining m−1m - 1 roads. Number the possible directions from 1 to mm from left to right from the approaching driver's point of view. Number 1 is a U-turn back along the road the driver used to approach the intersection, number 2 is a turn onto the leftmost road, and so on.

Suppose the road has nn lanes. Number the lanes from 1 to nn from left to right, so the leftmost lane is number 1, the next is number 2, and so on. A <> sign permits each lane to travel in some of the mm possible directions. The following conditions must hold:

  1. if travel in direction aa is permitted from lane ii, and travel in direction bb is permitted from lane jj, with i<ji < j, then a≤ba \le b;
  2. travel in at least one direction is permitted from each lane;
  3. travel from at least one lane is permitted in each direction.

The traffic safety inspection service is interested in how many different <> signs can be installed before such an intersection. Help them find the answer.

Input

The input file contains two integers: mm and nn (2≤m≤502 \le m \le 50, 1≤n≤151 \le n \le 15).

Output

Output a single number: the number of possible <> signs that can be installed before the intersection.

Hint

In the example, the following <> signs are possible:

From the left laneFrom the right lane
U-turnU-turn, left, straight, right
U-turnleft, straight, right
U-turn, leftleft, straight, right
U-turn, leftstraight, right
U-turn, left, straightstraight, right
U-turn, left, straightright
U-turn, left, straight, rightright

Examples1

  1. Example 1

    Input
    4 2
    
    Expected output
    7