Chemistry#7549

Chemistry

1 second
122.174 megabytes
Easy

The chemical formula of a molecule describes its atomic make-up. Chemical formulas obey the following grammar:

:= |

:= |

:= | '(' ')'

:= |

:= |

:= '' | ... | ''

:= '' | ... | ''

:= '' | ... | ''

:= | |

:= 'A' | ... | 'Z'

:= 'a' | ... | 'z'

The count represents a multiplier for the subgroup that precedes it. For example, H_2O has two (hydrogen) and one (oxygen) atoms, and (AlC_2)_3Na_4 contains (aluminum), (carbon) and (sodium) atoms.

Input

Contains multiple test cases. For each test case, there will be one line, containing a valid chemical formula. Each line will have no more than characters.

Output

For each line there will be one line of output which is the atomic decomposition of the chemical in the form of a sum as shown in the sample output. The atoms are listed in lexicographical order, and a count of is implied and not explicitly written. There are no blank spaces in the output. All of the counts in the correct output will be representable in -bit signed integers.

Examples

Example 1

Loading
Loading