You are given a rooted tree on n vertices, its root is the vertex number 1. The i-th vertex contains a number w_i. Split it into the minimum possible number of vertical paths in such a way that each path contains no more than L vertices and the sum of integers w_i on each path does not exceed S. Each vertex should belong to exactly one path.

A vertical path is a sequence of vertices v_1, v_2, …, v_k where v_i (i ≥ 2) is the parent of v_{i - 1}.

Input

The first line contains three integers n, L, S (1 ≤ n ≤ 10^5, 1 ≤ L ≤ 10^5, 1 ≤ S ≤ 10^{18}) — the number of vertices, the maximum number of vertices in one path and the maximum sum in one path.

The second line contains n integers w_1, w_2, …, w_n (1 ≤ w_i ≤ 10^9) — the numbers in the vertices of the tree.

The third line contains n - 1 integers p_2, …, p_n (1 ≤ p_i < i), where p_i is the parent of the i-th vertex in the tree.

Output

Output one number — the minimum number of vertical paths. If it is impossible to split the tree, output -1.

Examples

Input

3 1 3
1 2 3
1 1


Output

3

Input

3 3 6
1 2 3
1 1


Output

2

Input

1 1 10000
10001


Output

-1

Note

In the first sample the tree is split into \{1\},\ \{2\},\ \{3\}.

In the second sample the tree is split into \{1,\ 2\},\ \{3\} or \{1,\ 3\},\ \{2\}.

In the third sample it is impossible to split the tree.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import java.util.Map;
import java.util.Map.Entry;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author prakharjain
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        _1059E solver = new _1059E();
        solver.solve(1, in, out);
        out.close();
    }

    static class _1059E {
        List[] g;
        int[] height;
        int[] w;
        int L;
        long S;
        res[] res;
        long ans = 0;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            L = in.nextInt();

            S = in.nextLong();

            w = new int[n];

            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
                if (w[i] > S) {
                    out.println(-1);
                    return;
                }
            }

            g = new List[n];

            for (int i = 0; i < n; i++) {
                g[i] = new ArrayList();
            }

            for (int i = 1; i < n; i++) {
                int p = in.nextInt() - 1;
                g[p].add(i);
                g[i].add(p);
            }

            height = new int[n];
            res = new res[n];

            dfs(0, -1);

            ans += res[0].tm.size();

            out.println(ans);
        }

        void dfs(int u, int p) {

            int heightVer = -1;
            int maxHeight = 0;

            for (int v : (List<Integer>) g[u]) {
                if (v != p) {
                    dfs(v, u);
                    int newHeight = height[v] + 1;

                    if (newHeight > maxHeight) {
                        maxHeight = newHeight;
                        heightVer = v;
                    }
                }
            }

            height[u] = maxHeight;

            if (heightVer != -1) {
                res[u] = res[heightVer];
                res[u].extraLength++;
                res[u].extraWeight += w[u];

                res resu = res[u];

                Integer lastKey = resu.tm.size() > 0 ? resu.tm.lastKey() : null;
                while (lastKey != null && lastKey + resu.extraLength > L) {
                    ans++;
                    resu.tm.remove(lastKey);
                    if (resu.tm.size() > 0)
                        lastKey = resu.tm.lastKey();
                    else
                        lastKey = null;
                }

                Map.Entry<Integer, Long> firstEntry = resu.tm.firstEntry();
                while (firstEntry != null && firstEntry.getValue() + resu.extraWeight > S) {
                    ans++;
                    resu.tm.remove(firstEntry.getKey());
                    firstEntry = resu.tm.firstEntry();
                }


                for (int v : (List<Integer>) g[u]) {
                    if (v != p && v != heightVer) {
                        res resv = res[v];
                        int exL = resv.extraLength;
                        long exW = resv.extraWeight;
                        for (Integer len : resv.tm.keySet()) {
                            long wei = resv.tm.get(len);
                            len += exL;
                            wei += exW;

                            len++;
                            wei += w[u];

                            len -= resu.extraLength;
                            wei -= resu.extraWeight;

                            if (resu.tm.containsKey(len)) {
                                ans++;

                                resu.tm.merge(len, wei, (x, y) -> Math.min(x, y));
                            } else {
                                Integer floor = resu.tm.floorKey(len);
                                Integer ceil = resu.tm.ceilingKey(len);

                                while (ceil != null && resu.tm.get(ceil) >= wei) {
                                    ans++;
                                    resu.tm.remove(ceil);

                                    ceil = resu.tm.ceilingKey(len);
                                }

                                if (floor != null && resu.tm.get(floor) <= wei) {
                                    ans++;
                                } else {
                                    if (wei + resu.extraWeight <= S && len + resu.extraLength <= L)
                                        resu.tm.put(len, wei);
                                    else ans++;
                                }
                            }
                        }
                    }
                }

                if (resu.tm.size() == 0) {
                    resu.tm.put(1 - resu.extraLength, w[u] - resu.extraWeight);
                }
//            int len = 0 - resu.extraLength;
//            long wei = w[u] - resu.extraWeight;
//            Integer ceil = resu.tm.ceilingKey(len);
//
//            while (ceil != null && resu.tm.get(ceil) >= wei) {
//                ans++;
//                resu.tm.remove(ceil);
//
//                ceil = resu.tm.ceilingKey(len);
//            }
            } else {
                res[u] = new res();
                res resu = res[u];
                res[u].tm.put(1 - resu.extraLength, w[u] - resu.extraWeight);
//            int len = 0 - resu.extraLength;
//            long wei = w[u] - resu.extraWeight;
//            Integer ceil = resu.tm.ceilingKey(len);
//
//            while (ceil != null && resu.tm.get(ceil) >= wei) {
//                ans++;
//                resu.tm.remove(ceil);
//
//                ceil = resu.tm.ceilingKey(len);
//            }
            }
        }

        class res {
            TreeMap<Integer, Long> tm = new TreeMap<>();
            long extraWeight;
            int extraLength;

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

        public void println(int i) {
            writer.println(i);
        }

    }
}

