Олимпиадный тренинг

Задача 44645. tree height


Задача

Темы: Деревья

Implement a binary search tree for integers. The program receives a sequence of integers as input and builds a tree from them. Elements are added to the trees in accordance with the result of the search for their place. If the element already exists in the tree, you do not need to add it. The tree is not balanced.


Input

The program receives a sequence of natural numbers as input. The sequence ends with the number 0, which means the end of the input, and you do not need to add it to the tree.


Output

Print a single number – the height of the resulting tree.

The example matches the following tree:

 
Examples
# Input Output
1
7 3 2 1 9 5 4 6 8 0
4