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
Input Specification
The only line of input contains seven integers ranging from
Output Specification
Output one number - how many valid values of
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