All Tracks Problem

Infox Special
Tag(s):

BFS, Easy-Medium

Problem
Editorial
Analytics

Organization committee for techfest (INFOX) at USICT works in the following manner. Organization committee consists of n members (1 based indexing). There is always one head selected for the techfest and various other members work under him. Head of techfest has 1 index. Head is always at the top of hierarchy and other members work below him in hierarchy. Some of these members may be head themselves for small events and may have bunch of members working even under them. Head of the techfest is said to be at level 1 while level 2 comprises of members that work directly under him and members working under level 2 members are said to be in level 3 and so on levels are defined. A relation is defined between any head and a member working directly under him. Relation can exist only between members of consecutive levels. This is the hierarchy of techfest. Whole list of members for techfest have been uploaded and Gagan's level is 'l'. Your task is to find the total number of members working above the Gagan in the hierarchy.

Input:

First line contains n represting number of members. Next (n-1) lines contains two integers a and b which means a is related to b. Next line contains a variable 'l' represting the level of gagan.

Output:

You need to print a single integer denoting the answer to the query.

Constraints

1<=n<=50000

Note:

It is guaranteed that member at lower level cannot work under a member at higher level in hierarchy.

SAMPLE INPUT
6
1 3
2 4
4 6
1 5
2 1
4
SAMPLE OUTPUT
5
Explanation

Hierarchy can be represented as:

            1              ->level 1 (Head)

      /     |      \

    3       2        5      ->level 2

           |

           4              ->level 3

           |

           6               ->level 4

Gagan's level is 4. So total number of members working above the Gagan in the hierarchy is 1(level 3) +3(level 2)+1(level 1)=5

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), TypeScript, Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

University School of Information and Communication Technology, Guru Gobind Singh Indrapratha University, Delhi

Challenge Name

Codester Novice Prelims

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?