Helen studies functional programming and she is fascinated with a concept of higher order functions — functions that are taking other functions as parameters. She decides to generalize the concept of the function order and to test it on some examples.
For her study, she defines a simple grammar of types. In her grammar, a type non-terminal \(T\) is defined as one of the following grammar productions, together with \(\textrm{order}(T)\), defining an order of the corresponding type:
Helen asks for your help in writing a program that computes an order of the given type.
The single line of the input contains a string consisting of characters '(', ')', '-', and '>' that describes a type that is valid according to the grammar from the problem statement. The length of the line is at most \(10^4\) characters.
Print a single integer — the order of the given type.
()
0
()->()
1
()->()->()
(()->())->()
2
()->(((()->())->()->())->())
3
2000 ms 1024 Mb Правила оформления программ и список ошибок при автоматической проверке задач