You are given a tree with n vertices; its root is vertex 1. Also there is a token, initially placed in the root. You can move the token to other vertices. Let's assume current vertex of token is v, then you make any of the following two possible moves: 

  * move down to any leaf in subtree of v; 
  * if vertex v is a leaf, then move up to the parent no more than k times. In other words, if h(v) is the depth of vertex v (the depth of the root is 0), then you can move to vertex to such that to is an ancestor of v and h(v) - k ≤ h(to). 



Consider that root is not a leaf (even if its degree is 1). Calculate the maximum number of different leaves you can visit during one sequence of moves.

Input

The first line contains two integers n and k (1 ≤ k < n ≤ 10^6) — the number of vertices in the tree and the restriction on moving up, respectively.

The second line contains n - 1 integers p_2, p_3, ..., p_n, where p_i is the parent of vertex i.

It is guaranteed that the input represents a valid tree, rooted at 1.

Output

Print one integer — the maximum possible number of different leaves you can visit.

Examples

Input

7 1
1 1 3 3 4 4


Output

4


Input

8 2
1 1 2 3 4 5 5


Output

2

Note

The graph from the first example: 

<image>

One of the optimal ways is the next one: 1 → 2 → 1 → 5 → 3 → 7 → 4 → 6.

The graph from the second example: 

<image>

One of the optimal ways is the next one: 1 → 7 → 5 → 8. Note that there is no way to move from 6 to 7 or 8 and vice versa.

/**
 * Date: 12 Oct, 2018
 * Link:
 *
 * @author Prasad-Chaudhari
 * @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
 * @git: https://github.com/Prasad-Chaudhari
 */
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Stack;

public class newProgram {

    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        FastIO in = new FastIO();
        int n = in.ni();
        int k = in.ni();
        int from[] = new int[n - 1];
        int to[] = new int[n - 1];
        int count[] = new int[n + 1];
        int i = 0;
        while (i < n - 1) {
            from[i] = i + 2;
            to[i] = in.ni();
            ++count[from[i]];
            ++count[to[i]];
            ++i;
        }
        adja = new int[n + 1][];
        i = 0;
        while (i <= n) {
            adja[i] = new int[count[i]];
            ++i;
        }
        i = 0;
        while (i < n - 1) {
            adja[from[i]][--count[from[i]]] = to[i];
            adja[to[i]][--count[to[i]]] = from[i];
            ++i;
        }
        LinkedList<Integer> leaves = new LinkedList<>();
        i = 2;
        while (i <= n) {
            if (adja[i].length == 1) {
                leaves.add(i);
            }
            ++i;
        }
        st = new Stack<>();
        int parent[] = new int[n + 1];
        int true_parents[] = new int[n + 1];
        vi = new boolean[n + 1];
        int level[] = new int[n + 1];
        st.push(1);
        parent[1] = -1;
        true_parents[1] = -1;
        vi[1] = true;
        while (!st.isEmpty()) {
            int root = st.pop();
            for (int j : adja[root]) {
                if (!vi[j]) {
                    vi[j] = true;
                    parent[j] = root;
                    true_parents[j] = root;
                    level[j] = level[root] + 1;
                    st.push(j);
                }
            }
        }
        uf = new UnionFind(n + 2);
        Arrays.fill(vi, false);
        for (int l : leaves) {
            int curr = l;
            while (curr != -1 && level[l] - level[curr] <= k) {
                uf.union(l, curr);
                st.push(curr);
                curr = parent[curr];
            }
            while (!st.isEmpty()) {
                parent[st.pop()] = curr;
            }
        }
        noofleaves = new int[n + 1];
        for (int j : leaves) {
            noofleaves[uf.find(j)]++;
        }
        dp = new int[n + 1];
        st.push(1);
        vi[1] = true;
        Data d[] = new Data[n];
        i = 1;
        while (i <= n) {
            d[i - 1] = new Data(level[i], i, true_parents[i]);
            ++i;
        }
        Arrays.sort(d);
        int set[] = new int[n + 1];
        i = 1;
        while (i <= n) {
            set[i] = uf.find(i);
            ++i;
        }
        i = n - 1;
        while (i >= 1) {
            if (set[d[i].b] != set[d[i].c]) {
                dp[set[d[i].c]] = Math.max(dp[set[d[i].c]], noofleaves[set[d[i].b]] + dp[set[d[i].b]]);
//                System.out.println(d[i].b + " " + d[i].c);
            }
            --i;
        }
        System.out.println(dp[uf.find(1)] + noofleaves[uf.find(1)]);
    }
    static Stack<Integer> st;
    static int adja[][];
    static int dp[];
    static boolean vi[];
    static UnionFind uf;
    static int[] noofleaves;

    static class UnionFind {

        int parent[], size[], rank[];
        int n;

        public UnionFind(int n) {
            parent = new int[n + 1];
            rank = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                parent[i] = i;
                rank[i] = 1;
            }
        }

        public int find(int p) {
            if (parent[p] == p) {
                return p;
            } else {
                return find(parent[p]);
            }
        }

        public void union(int a, int b) {
            if (find(a) == find(b)) {
                return;
            }
//            System.out.println(a + " " + b);
            a = find(a);
            b = find(b);
//            System.out.println(a + " " + b);
            if (rank[a] >= rank[b]) {
                parent[b] = a;
//                System.out.println(b + "->" + a + "\n");
                rank[a]++;
            } else if (rank[a] > rank[b]) {
                parent[b] = a;
//                System.out.println(b + "->" + a + "\n");
            } else {
                parent[a] = b;
//                System.out.println(a + "->" + b + "\n");
            }
        }
    }

    static class FastIO {

        private final BufferedReader br;
        private final BufferedWriter bw;
        private String s[];
        private int index;
        private StringBuilder sb;

        public FastIO() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
//            br = new BufferedReader(new FileReader(new File("input")));
            bw = new BufferedWriter(new OutputStreamWriter(System.out, "UTF-8"));
            s = br.readLine().split(" ");
            sb = new StringBuilder();
            index = 0;
        }

        public int ni() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public double nd() throws IOException {
            return Double.parseDouble(nextToken());
        }

        public long nl() throws IOException {
            return Long.parseLong(nextToken());
        }

        public String next() throws IOException {
            return nextToken();
        }

        public String nli() throws IOException {
            try {
                return br.readLine();
            } catch (IOException ex) {

            }
            return null;
        }

        public int[] gia(int n) throws IOException {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }

        public int[] gia(int n, int start, int end) throws IOException {
            validate(n, start, end);
            int a[] = new int[n];
            for (int i = start; i < end; i++) {
                a[i] = ni();
            }
            return a;
        }

        public double[] gda(int n) throws IOException {
            double a[] = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }

        public double[] gda(int n, int start, int end) throws IOException {
            validate(n, start, end);
            double a[] = new double[n];
            for (int i = start; i < end; i++) {
                a[i] = nd();
            }
            return a;
        }

        public long[] gla(int n) throws IOException {
            long a[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }

        public long[] gla(int n, int start, int end) throws IOException {
            validate(n, start, end);
            long a[] = new long[n];
            for (int i = start; i < end; i++) {
                a[i] = nl();
            }
            return a;
        }

        public int[][] gg(int n, int m) throws IOException {
            int adja[][] = new int[n + 1][];
            int from[] = new int[m];
            int to[] = new int[m];
            int count[] = new int[n + 1];
            for (int i = 0; i < m; i++) {
                from[i] = ni();
                to[i] = ni();
                count[from[i]]++;
                count[to[i]]++;
            }
            for (int i = 0; i <= n; i++) {
                adja[i] = new int[count[i]];
            }
            for (int i = 0; i < m; i++) {
                adja[from[i]][--count[from[i]]] = to[i];
                adja[to[i]][--count[to[i]]] = from[i];
            }
            return adja;
        }

        public void print(String s) throws IOException {
            bw.write(s);
            bw.flush();
        }

        public void println(String s) throws IOException {
            bw.write(s);
            bw.newLine();
            bw.flush();
        }

        private String nextToken() throws IndexOutOfBoundsException, IOException {
            if (index == s.length) {
                s = br.readLine().split(" ");
                index = 0;
            }
            return s[index++];
        }

        private void validate(int n, int start, int end) {
            if (start < 0 || end >= n) {
                throw new IllegalArgumentException();
            }
        }
    }

    static class Data implements Comparable<Data> {

        int a, b, c;

        public Data(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public int compareTo(Data o) {
            if (a == o.a) {
                return Integer.compare(b, o.b);
            }
            return Integer.compare(a, o.a);
        }
    }
}
