Ordinal Number
시간 제한2초메모리 제한2048 MB
폰 노이만 순서수를 중괄호와 쉼표로 표현한 문자열이 주어질 때, 그것이 나타내는 정수 n을 구한다.
문제
Ordinal numbers are an extension of the set of nonnegative integers. For each nonnegative integer , we will establish the corresponding ordinal number . The first few ordinal numbers can be defined as follows.
- Zero corresponds to an empty set:
{}. - One corresponds to the set containing the set as an element:
{}{{}}. - Two corresponds to the set containing the sets and as elements:
{}{{},{{}}}. - And so on: each positive integer corresponds to the set containing all the previous ordinal numbers as elements. The formula is:
{}.
Next, we can similarly define ordinal numbers that don't correspond to integers. Alas, we won't need them in this problem.
You are given a string describing an ordinal number corresponding to a nonnegative integer . Find .
입력
The first line contains the description of an ordinal number corresponding to a certain nonnegative integer (). It consists of the characters "{", ",", and "}".
In the description of each set, each element appears exactly once. However, as a set does not change if we change the order of elements, this order can be arbitrary.
출력
Print the integer corresponding to the given ordinal number.