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.IOException; 
import java.io.InputStream; 
import java.io.PrintWriter; 
import java.util.*; 
 

public class e{
	static class Node{
		TreeMap<Integer, Long> tmap=new TreeMap<>();
		int l;
		long w;
		Node(long w){
			l=1;this.w=w;
			tmap.put(0, 0l);
		}
	}
	static List<Integer> edges[];
	static long[] w;
	static int L;
	static long S;
	static int ans = 0;


	static Node dfs(int v){
		List<Node> nodes = new ArrayList<>();
		for(int u: edges[v])nodes.add(dfs(u));
		Collections.sort(nodes, (a,b)->b.tmap.size()-a.tmap.size());
		if(nodes.size()==0){
			Node res = new Node(w[v]);
			return res;
		}
		Node root = nodes.get(0);
		List<Integer> del = new ArrayList<>();
		for(Map.Entry<Integer, Long> entry: root.tmap.entrySet()){
			if(entry.getKey() + root.l +1 > L){
				++ans; del.add(entry.getKey());
			}else if(entry.getValue()+root.w + w[v]>S){
				++ans; del.add(entry.getKey());
			}
		}
		for(int key: del)root.tmap.remove(key);

		for(int i=1;i<nodes.size();++i){
			Node node = nodes.get(i);
			for(Map.Entry<Integer, Long> entry: node.tmap.entrySet()){
				if(entry.getKey() + node.l +1 > L){
					++ans;continue;
				}
				if(entry.getValue()+node.w + w[v]>S){
					++ans;continue;
				}
				Map.Entry<Integer, Long> floor = root.tmap.floorEntry(entry.getKey()+node.l-root.l);
				if(floor !=null && floor.getValue() <= entry.getValue() + node.w-root.w){
					++ans;
					continue;
				}
				while(true){
					Map.Entry<Integer, Long> ceil = root.tmap.ceilingEntry(entry.getKey()+node.l-root.l);
					if(ceil == null || ceil.getValue() + root.w < entry.getValue() + node.w)break;
					root.tmap.remove(ceil.getKey());
					++ans;
				}
				root.tmap.put(entry.getKey()+node.l-root.l, entry.getValue() + node.w - root.w);
			}
		}
		root.l += 1;
		root.w += w[v];
		while(true){
			Map.Entry<Integer, Long> entry = root.tmap.lastEntry();
			if(entry == null || entry.getKey() + root.l <= L)break;
			root.tmap.remove(entry.getKey());
			++ans;
		}
		while(true){
			Map.Entry<Integer, Long> entry = root.tmap.firstEntry();
			if(entry == null || entry.getValue() + root.w <=S)break;
			root.tmap.remove(entry.getKey());
			++ans;
		}
		if(root.tmap.size()==0){
			root = new Node(w[v]);
		}
		return root;
	}

	static void solve(){
		int n = ni();
		L = ni();
		S = nl();
		w = nla(n);
		for(int i=0;i<n;++i){
			if(w[i]>S){
				out.println(-1);return;
			}
		}
		edges = new List[n];
		for(int i=0;i<n;++i)edges[i] =new ArrayList<>();
		for(int i=1;i<n;++i){
			int p = ni();
			edges[p-1].add(i);
		}
		Node node = dfs(0);
		out.println(ans + node.tmap.size());
	} 
 
 
 
 
	 public static void main(String[] args){ 
		 solve(); 
		 out.flush(); 
	 } 
	 private static InputStream in = System.in; 
	 private static PrintWriter out = new PrintWriter(System.out); 
 
	 static boolean inrange(int y, int x, int h, int w){ 
		 return y>=0 && y<h && x>=0 && x<w; 
	 } 
	 @SuppressWarnings("unchecked") 
	 static<T extends Comparable> int lower_bound(List<T> list, T key){ 
		 int lower=-1;int upper=list.size(); 
		 while(upper - lower>1){ 
		 int center =(upper+lower)/2; 
		 if(list.get(center).compareTo(key)>=0)upper=center; 
		 else lower=center; 
		 } 
		 return upper; 
	 } 
	 @SuppressWarnings("unchecked") 
	 static <T extends Comparable> int upper_bound(List<T> list, T key){ 
		 int lower=-1;int upper=list.size(); 
		 while(upper-lower >1){ 
		 int center=(upper+lower)/2; 
		 if(list.get(center).compareTo(key)>0)upper=center; 
		 else lower=center; 
		 } 
		 return upper; 
	 } 
	 @SuppressWarnings("unchecked") 
	 static <T extends Comparable> boolean next_permutation(List<T> list){ 
		 int lastIndex = list.size()-2; 
		 while(lastIndex>=0 && list.get(lastIndex).compareTo(list.get(lastIndex+1))>=0)--lastIndex; 
		 if(lastIndex<0)return false; 
		 int swapIndex = list.size()-1; 
		 while(list.get(lastIndex).compareTo(list.get(swapIndex))>=0)swapIndex--; 
		 T tmp = list.get(lastIndex); 
		 list.set(lastIndex++, list.get(swapIndex)); 
		 list.set(swapIndex, tmp); 
		 swapIndex = list.size()-1; 
		 while(lastIndex<swapIndex){ 
		 tmp = list.get(lastIndex); 
		 list.set(lastIndex, list.get(swapIndex)); 
		 list.set(swapIndex, tmp); 
		 ++lastIndex;--swapIndex; 
		 } 
		 return true; 
	 } 
	 private static final byte[] buffer = new byte[1<<15]; 
	 private static int ptr = 0; 
	 private static int buflen = 0; 
	 private static boolean hasNextByte(){ 
		 if(ptr<buflen)return true; 
		 ptr = 0; 
		 try{ 
			 buflen = in.read(buffer); 
		 } catch (IOException e){ 
			 e.printStackTrace(); 
		 } 
		 return buflen>0; 
	 } 
	 private static int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;} 
	 private static boolean isSpaceChar(int c){ return !(33<=c && c<=126);} 
	 private static int skip(){int res; while((res=readByte())!=-1 && isSpaceChar(res)); return res;} 
 
	 private static double nd(){ return Double.parseDouble(ns()); } 
	 private static char nc(){ return (char)skip(); } 
	 private static String ns(){ 
		 StringBuilder sb = new StringBuilder(); 
		 for(int b=skip();!isSpaceChar(b);b=readByte())sb.append((char)b); 
		 return sb.toString(); 
	 } 
	 private static int[] nia(int n){ 
		 int[] res = new int[n]; 
		 for(int i=0;i<n;++i)res[i]=ni(); 
		 return res; 
	 } 
	 private static long[] nla(int n){ 
		 long[] res = new long[n]; 
		 for(int i=0;i<n;++i)res[i]=nl(); 
		 return res; 
	 } 
	 private static int ni(){ 
		 int res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	 } 
	 private static long nl(){ 
		 long res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	} 
} 

