Time Limit: 1 Sec Memory Limit: 128 MB
LowbieH and Peggy are in the playroom to figure out an interesting problem. Given a string of matched parenthesis
- If
$s=()$ , then$score(s)=1$ . - If
$t$ is another string of matched parenthesis, then$score(s+t)=score(s)+score(t)$ . -
$score((s))=score(s)∗2$ .
LowbieH and Peggy want to calculate the score of given string quickly, can you help them? Since the answer may be very large, you only need to tell them the score after mod
One line a string. It contains only parenthesis and is perfect matched. The length of input will not exceed
One line an integer, denoting the score (mod
((()())())
10