eolymp
bolt
Try our new interface for solving problems
Problems

Brackets

Brackets

Given an expression consisting only of letters \textbf{a} digits and the operations \textbf{+} and \textbf{*}. Write a program that computes the number of ways of placing a full set of brackets in this expression so that each pair of brackets contain a single character operation and two operands, each of which is either \textbf{a} letter or an expression in parentheses. Value of the expression at the same time should remain unchanged, ie must first run the operations of multiplication and then addition. For example, the expression \textbf{а}+\textbf{а}+\textbf{а}*\textbf{а}*\textbf{а} there are \textbf{4} ways to placement of brackets: (а+(а+(а*(а*а)))) (а+(а+((а*а)*а))) ((а+а)+((а*а)*а)) ((а+а)+(а*(а*а))) \InputFile In the first line of the input file contains a valid expression containing no more than \textbf{25} characters of operations. \OutputFile In the output file display one number - the number of ways of placing parentheses.
Time limit 1 second
Memory limit 64 MiB
Input example #1
a+a+a*a*a
Output example #1
4