#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long sum = 0, ff = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) ff = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) sum = sum * 10 + ch -  0 , ch = getchar();     return sum * ff;   }   const int N = 100007;   const int block = 500;   int n, m, a_st[N], a[N], x, y, num, belong[N], st[N / block + 7],       ed[N / block + 7], col[N], sum[N / block + 7][N * 2], tag[N / block + 7],       ans;   struct edge {     int to, nxt;   } e[N];   int cnt, he[N];   void add(int u, int v) {     e[++cnt].to = v;     e[cnt].nxt = he[u];     he[u] = cnt;   }   int deep[N], siz[N], fa[N], son[N], dfs_cnt, dfn[N], top[N];   void dfs1(int u, int fat) {     deep[u] = deep[fat] + 1;     siz[u] = 1;     fa[u] = fat;     for (int i = he[u]; i; i = e[i].nxt) {       int v = e[i].to;       if (v == fat) continue;       dfs1(v, u);       siz[u] += siz[v];       if (siz[v] > siz[son[u]]) son[u] = v;     }   }   void dfs2(int u, int tp) {     top[u] = tp;     dfn[u] = ++dfs_cnt;     if (!son[u]) return;     dfs2(son[u], tp);     for (int i = he[u]; i; i = e[i].nxt) {       int v = e[i].to;       if (top[v]) continue;       dfs2(v, v);     }   }   void build() {     for (int i = 1; i <= n; i++) belong[i] = (i - 1) / block + 1;     num = belong[n];     for (int i = 1; i <= num; i++) st[i] = (i - 1) * block + 1, ed[i] = i * block;     ed[num] = n;   }   void change(int x, int y) {     col[x] ^= 1;     if (a[x] >= n + 1 - tag[belong[x]]) ans -= y;     sum[belong[x]][a[x]] -= y;   }   void upd(int l, int r, int val) {     for (int i = l; i <= r; i++) {       if (!col[i] && a[i] >= n + 1 - tag[belong[i]]) ans--;       if (!col[i]) sum[belong[i]][a[i]]--;       a[i] += val;       if (!col[i]) sum[belong[i]][a[i]]++;       if (!col[i] && a[i] >= n + 1 - tag[belong[i]]) ans++;     }   }   void modify(int l, int r, int val) {     if (belong[l] == belong[r]) {       upd(l, r, val);       return;     }     upd(l, ed[belong[l]], val), upd(st[belong[r]], r, val);     for (int i = belong[l] + 1; i < belong[r]; i++) {       if (val == 1)         tag[i]++, ans += sum[i][n + 1 - tag[i]];       else         ans -= sum[i][n + 1 - tag[i]], tag[i]--;     }   }   int main() {     n = read(), m = read();     for (int i = 2; i <= n; i++) fa[i] = read(), add(fa[i], i);     for (int i = 1; i <= n; i++) a_st[i] = read();     dfs1(1, 0);     dfs2(1, 1);     for (int i = 1; i <= n; i++) a[dfn[i]] = n - a_st[i];     build();     for (int i = 1; i <= n; i++) sum[belong[i]][a[i]]++;     for (int i = 1; i <= m; i++) {       x = read();       y = (x > 0) ? 1 : -1;       x = abs(x);       change(dfn[x], y);       while (x) {         modify(dfn[top[x]], dfn[x], y);         x = fa[top[x]];       }       cout << ans <<    ;     }     return 0;   }   