QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 16 MB Total points: 100

#22824. Cowfix

Statistics

Expressions are commonly written in infix notation, with a binary operator between its operands, as in 1+2 or 7*(5-3). In prefix notation the operator comes before its operands, as in + 1 2 or * 7 - 5 3. In postfix notation the operator comes after its operands, as in 1 2 + or 7 5 3 - *. Prefix and postfix notation do not use parentheses.

Farmer John's cows often mix these three notations. They write expressions in cowfix, using single-digit numbers and the binary operators + and -. An expression may be interpreted using any mixture of infix, prefix, and postfix rules. For example, +54+-82 can be evaluated at least two ways:

+ 5 4 + - 8 2 = 9 + - 8 2 = 9 + 6 = 15
+ 5 4 + - 8 2 = + 9 - 8 2 = + 1 2 = 3

The expression 9-4+3 evaluates to both $2$ and $8$. Given a cowfix expression, determine the number of distinct values it may evaluate to. The input is guaranteed to be a syntactically valid cowfix expression.

Input

One string of at most 80 characters, containing no blanks.

Output

One line containing the number of different possible values.

Examples

Input 1

+54+-82

Output 1

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.