The National Genealogical Society (NGS) is a non governmental organization dedicated to assisting its members in genealogical research. Elections for the Executive Board of the Society are currently underway.
All members of the NGS are eligible voters, each having a number of votes equal to the rank level of his or her officially registered genealogical tree. The rank level of a tree depends on its size and shape, and is statutorily defined as follows:
The following tree contains 3 complete paths: two of height 3 and one of height 4. The rank level of this tree is therefore (3+3+4)/3 = 3, hence the number of votes of Mary John is 3.
Write a program that calculates the rank level of a given genealogical tree.
Input
The input contains a genealogical tree, organized according to the following recursive rules.
The output consists of a single line
that contains the rank level of the tree (an integer).
Sample Input
Mary John Thomas John Efstration John . . Diamantina Kaskabas . . Sarah Sally . Mary Ann John Smith . . .
3