Problem C

Elections in the National Genealogical Society

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.

The empty tree has rank level 0. A tree with a single node has rank level 1.

Problem

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 input tree can have up to 100 levels, but never more than 2 million nodes.
The maximum length of a name is 20 characters.

Output

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
.
.
.

Sample Output

3


CPN'2003: 1st Concurso de Programação da Nova --- 2nd Leg
Departamento de Informática
Faculdade de Ciências e Tecnologia
Universidade Nova de Lisboa