시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 5 5 4 100.000%

## 문제

Peter is a math teacher at an elementary school. To familiarize students with three basic arithmetic operations plus (+), minus (−) and times (×), he gives a simple arithmetic puzzle as homework. The puzzle is that you are given 4 digits, and you are told to build as many non-negative integers as possible using just those 4 digits and at least one of the three basic arithmetic operations. For example, you are given 1,1,2,1 as the digits, and then you can build 32 non-negative integers as Table 1.

Table 1: Numbers made by 1,1,2,1.

 0 = 2 − 1 − 1 × 1 1 = 2 + 1 − 1 − 1 2 = 2 + 1 − 1 × 1 3 = 2 + 1 + 1 − 1 4 = 2 + 1 + 1 × 1 5 = 2 + 1 + 1 + 1 8 = 11 − 2 − 1 9 = 11 − 2 × 1 10 = 12 − 1 − 1 11 = 12 − 1 × 1 12 = 12 + 1 − 1 13 = 12 + 1 × 1 14 = 12 + 1 + 1 19 = 21 − 1 − 1 20 = 21 − 1 × 1 21 = 21 + 1 − 1 22 = 21 + 1 × 1 23 = 21 + 1 + 1 32 = 21 + 11 109 = 111 − 2 111 = 112 − 1 112 = 112 × 1 113 = 112 + 1 120 = 121 − 1 121 = 121 × 1 122 = 121 + 1 132 = 12 × 11 210 = 211 − 1 211 = 211 × 1 212 = 211 + 1 222 = 111 × 2 231 = 21 × 11

To check whether the student’s answer includes all possible integers, Peter needs to know the total number of non-negative integers that can be built for the puzzle. Please write a program to help Peter compute the total number.

## 입력

The input file contains 4 integers separated by a space in a line, which indicates the given digits.

## 출력

Output the total number of non-negative integers that can be built.

## 제한

• The expressions are composed by concatenating the 4 given digits and at least one operation in {+, −, ×}. The given digits are the elements in {1, 2, 3, . . . 9}.
• The given digits are partitioned into several groups and the digits in each group are concatenated as a number in arbitrarily permutation order.
• The symbol − can only be treated as a minus operator.
• The operations + and − have equal precedence.
• The operation × has higher precedence than + and −.
• Operations with the highest precedence are evaluated first, and operations with equal precedence are evaluated from left to right.

## 예제 입력 1

1 1 1 1


## 예제 출력 1

15


## 예제 입력 2

1 1 2 1


## 예제 출력 2

32