You are cooking a large, seven-layer cake for an upcoming party. You have very little time left, so you would like to complete the cake in as little time as possible.
The recipe for the cake requires different ingredients, numbered from 1 to . The cake itself is considered an ingredient with index . Each ingredient takes an hour to prepare, however some ingredients require other ingredients to be prepared first. For example, a "frosting" ingredient might require the "sugar", "butter", and "milk" ingredients to be prepared first. Each ingredient (excluding the cake) is used as a component of exactly one other ingredient.
You can prepare at most ingredients at a time. Given these constraints, what is the minimum amount of time required for you to prepare the cake?
The first line of input contains the integers and , the number of ingredients and the number of ingredients you can prepare at the same time. The next line contains integers , stating that ingredient is required for ingredient .
For 40 of 100 points, .
Output the minimum number of hours required to prepare the cake.
Sample Input 1
2 1 3 3
Sample Output 1
Sample Input 2
4 2 3 3 5 5
Sample Output 2