#include<cstdio>
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#define ll long long
#define INF_INT 0x3f3f3f3f
char Ch;
int ff;
inline void rd(int &x){
x=0,ff=1,Ch=getchar();
while((Ch<'0'||Ch>'9')&&Ch!='-')Ch=getchar();
if(Ch=='-')Ch=getchar(),ff=-1;
while(Ch>='0'&&Ch<='9'){
x=(x<<1)+(x<<3)+Ch-'0';
Ch=getchar();
}
x*=ff;
}
inline int random(int x){
return (long long)rand()*rand()%x;
}
using namespace std;
const int N=1e5+5;
int n,Q,sign;
int prt[N],sz[N],dep[N],son[N];
int top[N],pos[N];
vector<int>v[N];
char op[14];
void dfs1(int x){
sz[x]=1;
for(auto y:v[x]){
dep[y]=dep[x]+1;
dfs1(y);
sz[x]+=sz[y];
if(sz[y]>sz[son[x]])son[x]=y;
}
}
void dfs2(int x,int f){
top[x]=f;
pos[x]=++sign;
if(!son[x])return ;
dfs2(son[x],f);
for(auto y:v[x])
if(y!=son[x])
dfs2(y,y);
}
struct Seg_Tree{
#define mid (l+r>>1)
#define Ls x<<1,l,mid
#define Rs x<<1|1,mid+1,r
int t[N<<2],add[N<<2];
int len[N<<2];
inline void push_up(int x){
t[x]=t[x<<1]+t[x<<1|1];
}
inline void push_down(int x){
if(add[x]!=-1){
add[x<<1]=add[x];
add[x<<1|1]=add[x];
t[x<<1]=len[x<<1]*add[x];
t[x<<1|1]=len[x<<1|1]*add[x];
add[x]=-1;
}
}
void build(int x,int l,int r){
len[x]=r-l+1;
add[x]=-1;
if(l==r)
return ;
build(Ls);
build(Rs);
}
void upd(int x,int l,int r,int L,int R,int val){
if(l>=L&&r<=R){
add[x]=val;
t[x]=len[x]*val;
return ;
}
push_down(x);
if(L<=mid)upd(Ls,L,R,val);
if(R>mid)upd(Rs,L,R,val);
push_up(x);
}
int ask(int x,int l,int r,int L,int R){
if(l>=L&&r<=R)return t[x];
push_down(x);
int ans=0;
if(L<=mid)ans+=ask(Ls,L,R);
if(R>mid)ans+=ask(Rs,L,R);
push_up(x);
return ans;
}
}seg;
int Upd(int x,int y){
int fx=top[x],fy=top[y];
while(fx!=fy){
if(dep[fx]<dep[fy])
swap(x,y),swap(fx,fy);
seg.upd(1,1,n,pos[fx],pos[x],1);
x=prt[fx],fx=top[x];
}
if(dep[x]>dep[y])swap(x,y);
seg.upd(1,1,n,pos[x],pos[y],1);
}
int main(){
srand(time(0));
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
scanf("%d",&n);
for(int i=2,x;i<=n;i++){
scanf("%d",&prt[i]),prt[i]++;
v[prt[i]].push_back(i);
}
scanf("%d",&Q);
dfs1(1);
dfs2(1,1);
seg.build(1,1,n);
for(int x,t1,t2;Q--;){
scanf("\n%s %d",op,&x);
x++;
t1=seg.t[1];
if(op[0]=='i')
Upd(1,x);
else
seg.upd(1,1,n,pos[x],pos[x]+sz[x]-1,0);
t2=seg.t[1];
printf("%d\n",abs(t1-t2));
}
return 0;
}