Make Numbers

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

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 × 11 = 2 + 1 − 1 − 12 = 2 + 1 − 1 × 13 = 2 + 1 + 1 − 14 = 2 + 1 + 1 × 15 = 2 + 1 + 1 + 18 = 11 − 2 − 19 = 11 − 2 × 1
10 = 12 − 1 − 111 = 12 − 1 × 112 = 12 + 1 − 113 = 12 + 1 × 114 = 12 + 1 + 119 = 21 − 1 − 120 = 21 − 1 × 121 = 21 + 1 − 1
22 = 21 + 1 × 123 = 21 + 1 + 132 = 21 + 11109 = 111 − 2111 = 112 − 1112 = 112 × 1113 = 112 + 1120 = 121 − 1
121 = 121 × 1122 = 121 + 1132 = 12 × 11210 = 211 − 1211 = 211 × 1212 = 211 + 1222 = 111 × 2231 = 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.