#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     int v = 0, f = 1;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - )       f = -1;     else       v = (c & 15);     while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);     x = v * f;   }   inline void read(long long &x) {     long long v = 0ll, f = 1ll;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - )       f = -1;     else       v = (c & 15);     while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);     x = v * f;   }   inline void readc(char &x) {     char c;     while (((c = getchar()) ==    ) || c ==   n )       ;     x = c;   }   inline void writes(string s) { puts(s.c_str()); }   inline void writeln() { writes(  ); }   inline void writei(int x) {     if (x < 0) {       putchar( - );       x = abs(x);     }     if (!x) putchar( 0 );     char a[25];     int top = 0;     while (x) {       a[++top] = (x % 10) +  0 ;       x /= 10;     }     while (top) {       putchar(a[top]);       top--;     }   }   inline void writell(long long x) {     if (x < 0) {       putchar( - );       x = abs(x);     }     if (!x) putchar( 0 );     char a[25];     int top = 0;     while (x) {       a[++top] = (x % 10) +  0 ;       x /= 10;     }     while (top) {       putchar(a[top]);       top--;     }   }   int n, m, i, j, lst, t[100005], w[100005], col[100005], dfn[100005],       fa[100005][19], dep[100005], stk[100005], tp, blk, ti, a[100005],       ixt[100005], ans[100005], cur, dup[100005], ixf[100005], cq, duv[100005];   vector<int> e[100005], ee[100005], all, tmp;   vector<pair<int, int> > dur[100005];   int seq[100005];   void add(int x, int y) {     all.push_back(x);     all.push_back(y);     ee[x].push_back(y);     ee[y].push_back(x);   }   int lca(int x, int y) {     if (dep[x] < dep[y]) {       swap(x, y);     }     int t = dep[x] - dep[y], i;     for ((i) = (18); (i) >= (0); (i)--) {       if ((t >> i) & 1) {         x = fa[x][i];       }     }     if (x == y) return x;     for ((i) = (18); (i) >= (0); (i)--) {       if (fa[x][i] != fa[y][i]) {         x = fa[x][i];         y = fa[y][i];       }     }     return fa[x][0];   }   void dfs(int x) {     dfn[x] = ++ti;     for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++) {       dep[*it] = dep[x] + 1;       dfs(*it);     }   }   void dfs2(int x) {     for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++) {       dfs2(*it);       w[x] += w[*it];     }   }   bool cmp(int x, int y) { return dfn[x] < dfn[y]; }   void ins(int x) {     if (tp <= 1) {       stk[++tp] = x;       return;     }     int z = lca(stk[tp], x);     if (z == stk[tp]) {       stk[++tp] = x;       return;     }     while (tp > 1 && dfn[stk[tp - 1]] >= dfn[z]) {       add(stk[tp], stk[tp - 1]);       tp--;     }     if (stk[tp] != z) {       add(stk[tp], z);       stk[tp] = z;     }     stk[++tp] = x;   }   void ine(int x, int y) {     int id = y;     duv[id] = 0;     y = fa[y][0];     tmp.clear();     while (y != x) {       ixt[y] = 1;       if (!col[y]) tmp.push_back(t[y] - w[y]);       y = fa[y][0];     }     sort(tmp.begin(), tmp.end());     dur[id].clear();     for (__typeof((tmp).begin()) it = (tmp).begin(); it != (tmp).end(); it++) {       if (dur[id].empty()) {         dur[id].push_back(make_pair(*it, 1));       } else if (dur[id].back().first == *it) {         dur[id].back().second++;       } else {         dur[id].push_back(make_pair(*it, dur[id].back().second + 1));       }     }     for (dup[id] = 0; dup[id] < dur[id].size(); dup[id]++)       if (duv[id] <= dur[id][dup[id]].first) break;     dup[id]--;     cur += (dup[id] == -1 ? 0 : dur[id][dup[id]].second);   }   void dfs3(int x, int fa) {     ixf[x] = fa;     ixt[x] = 1;     if (!col[x]) cur += (w[x] > t[x]);     for (__typeof((ee[x]).begin()) it = (ee[x]).begin(); it != (ee[x]).end();          it++)       if (*it != fa) {         ine(x, *it);         dfs3(*it, x);       }   }   void dfs4(int x) {     if (!ixt[x]) {       if (!col[x]) cur += (w[x] > t[x]);     }     for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++) {       dfs4(*it);     }   }   void upe(int x, int dlt) {     duv[x] += dlt;     cur -= (dup[x] == -1 ? 0 : dur[x][dup[x]].second);     while (dup[x] + 1 < dur[x].size() && duv[x] > dur[x][dup[x] + 1].first)       dup[x]++;     while (dup[x] > -1 && duv[x] <= dur[x][dup[x]].first) dup[x]--;     cur += (dup[x] == -1 ? 0 : dur[x][dup[x]].second);   }   void work(int x) {     int dlt = x / abs(x), fst = 1;     x = abs(x);     while (x) {       if (!col[x]) cur -= (w[x] > t[x]);       if (fst) col[x] += dlt;       fst = 0;       w[x] += dlt;       if (!col[x]) cur += (w[x] > t[x]);       if (x != 1) upe(x, dlt);       x = ixf[x];     }   }   void solve(int ed) {     int i;     cur = 0;     all.clear();     memset(w, 0, sizeof(w));     memset(ixt, 0, sizeof(ixt));     for (((i)) = (1); ((i)) <= ((lst)); ((i))++) {       if (seq[i] > 0) {         w[seq[i]] = col[seq[i]] = 1;       } else {         w[-seq[i]] = col[-seq[i]] = 0;       }     }     dfs2(1);     for ((i) = (lst + 1); (i) <= (ed); (i)++) {       a[i - lst] = abs(seq[i]);     }     sort(a + 1, a + (ed - lst) + 1, cmp);     stk[tp = 1] = 1;     for (((i)) = (1); ((i)) <= ((ed - lst)); ((i))++) {       if (a[i] != 1 && a[i] != a[i - 1]) {         ins(a[i]);       }     }     while (tp >= 2) {       add(stk[tp], stk[tp - 1]);       tp--;     }     dfs3(1, 0);     dfs4(1);     for ((i) = (lst + 1); (i) <= (ed); (i)++) {       work(seq[i]);       printf( %d  , cur);     }     for (__typeof((all).begin()) it = (all).begin(); it != (all).end(); it++) {       ee[*it].clear();     }   }   int main() {     read(n);     read(m);     blk = sqrt(m) * 2;     for ((i) = (2); (i) <= (n); (i)++) {       scanf( %d , &fa[i][0]);       e[fa[i][0]].push_back(i);     }     for (((j)) = (1); ((j)) <= ((18)); ((j))++)       for (((i)) = (1); ((i)) <= ((n)); ((i))++) {         fa[i][j] = fa[fa[i][j - 1]][j - 1];       }     for (((i)) = (1); ((i)) <= ((n)); ((i))++) {       scanf( %d , &t[i]);     }     dfs(1);     lst = 0;     for (((i)) = (1); ((i)) <= ((m)); ((i))++) {       scanf( %d , &seq[i]);       if (i % blk == 0) {         solve(i);         lst = i;       }     }     if (lst < m) solve(m);     return 0;   }