colorful-balls

Today Oz is playing with colorful balls. He has A  red balls, B  blue balls, C  green balls and D yellow balls. Using the balls, he wants to make a colorful straight line such that no two balls of same type are adjacent to each other. He also knows that their are many ways to make colorful straight line keeping the condition so first he wants to know how many ways are their to make colorful straight line. Help Oz with the answer.

Note:
Each ball of a given type is identical to others of the same type, thus swapping the positions of two of the same type of balls does not make a new arrangement.

Input:
First and the only line of the input contains four single space separated integers i.e A, B, C  and D as described in the problem statement.

Output:
Output the number of ways to make a colorful straight line.

Constraints:
A , B, C and D ≤ 10

SAMPLE INPUT
2 2 0 0

SAMPLE OUTPUT
2

Explanation

There are two possible arrangements: RBRB or BRBR where 'B' indicates a blue ball and 'R' indicates a red ball.

Source: hackerearth | Difficulty: EASY
Tags: Dynamic programming

Combinatorics


Solutions: