When it's freezing outside, there isn't much to do in Waterloo. Luckily for you, you stumbled onto the "Black Square" painting by Kazimir Malevich. While that painting is literally just a black square, you were marveled by its simplicity and use of color. And that's how your weekend art project was born. You took some old jigsaw puzzle and painted every single puzzle piece black. As a result, you ended up with pieces of seven kinds, as shown in the picture below. You have varying quantities of each kind. By interlocking puzzle pieces, you connect them together. The "Black Square" was already painted and you're interested in making frames for it, which also must be completely black. Since you're also interested in combinatorics, the following question entered your mind.
You're interested in how many integers exist such that you can make an by frame from the jigsaw puzzle pieces that you have (each puzzle piece is by ). You don't have to use every single puzzle piece that you have. You can rotate puzzle pieces but you are not allowed to flip them over (as the back texture is not the same as the front texture). An by square frame is a structure of size by whose by interior is completely empty. That means that you cannot have any puzzle parts sticking in or out, nor can you have any emptiness left in a puzzle piece. Lastly, each puzzle piece has to be connected to exactly two other puzzle pieces. This means that putting two flat sides together does not count as a valid connection.
Input Specification
The only line of input contains seven integers ranging from to (inclusive) - the quantities of each puzzle piece kind. The order of input corresponds to the order shown in the image (so the first integer is the count of the leftmost puzzle piece kind, and so on).
Output Specification
Output one number - how many valid values of exist.
Sample Input 1
0 0 4 0 4 0 2
Sample Output 1
1
Sample Input 2
1 1 1 1 1 1 1
Sample Output 2
0
Sample Input 3
0 4 0 4 4 4 12
Sample Output 3
5
Comments