Under construction

Still being built. Things may change

Jumping on a Tree

Time limit4sMemory limit512 MB

Summary
Given a tree and an integer d, count the groups of vertices that are linked by jumps between pairs exactly d edges apart.
Level

Medium7 of 10

Topics
Tree, Union-find, DFS
Solved
No attempts yet

Problem

You are given a tree on nn vertices. Suppose we are at the vertex vv. In one step we can go from vv to any other vertex uu such that there are exactly dd edges on the shortest path between vv and uu. A vertex uu is reachable from vv if we can get to uu from vv using zero or more steps.

Naturally, all vertices can be divided into reachability classes. A reachability class is a set of vertices CC such that any vertex in CC is reachable from any other vertex in CC, but no vertex outside CC is reachable from any vertex in CC. How many reachability classes are there in the given tree?

Input

The first line contains two space-separated integers nn and dd (1≤n≤1061 \leq n \leq 10^6, 0≤d≤n0 \leq d \leq n).

Next n−1n - 1 lines describe the edges of the tree. Each line contains two space-separated integers, the indices of the vertices connected by the edge. Indices are 1-based.

Output

Print one integer, the number of reachability classes.

Examples1

  1. Example 1

    Input
    4 2
    1 2
    2 3
    3 4
    
    Expected output
    2