#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
const int N=100009;
struct Edge
{
int v,next;
}edge[N];
struct Hash
{
int a,b;
}h[N];
struct Tree
{
int cover,val;
}tree[N<<2];
int cur,head[N];
void dfs(int x)
{
if(x<=0) return;
cur++;
h[x].a=cur;
int e=head[x];
while(e>0)
{
dfs(edge[e].v);
e=edge[e].next;
}
h[x].b=cur;
}
void build(int l,int r,int id)
{
tree[id].cover=tree[id].val=0;
if(l<r)
{
int mid=(l+r)>>1;
build(l,mid,id<<1);
build(mid+1,r,id<<1|1);
}
}
void pushup(int id)
{
tree[id].val=tree[id<<1].val+tree[id<<1|1].val;
}
void pushdown(int l,int r,int id)
{
if(tree[id].cover)
{
tree[id<<1].cover ^= 1;
tree[id<<1|1].cover ^= 1;
int mid=(l+r)>>1;
tree[id<<1].val=mid-l+1-tree[id<<1].val;
tree[id<<1|1].val=r-mid-tree[id<<1|1].val;
tree[id].cover=0;
}
}
int answer(int L,int R,int l,int r,int id)
{
if(L<=l && r<=R) return tree[id].val;
pushdown(l,r,id);
int ans=0,mid=(l+r)>>1;
if(L<=mid) ans+=answer(L,R,l,mid,id<<1);
if(R>=mid+1) ans+=answer(L,R,mid+1,r,id<<1|1);
return ans;
}
void insert(int L,int R,int l,int r,int id)
{
if(L<=l && r<=R)
{
tree[id].cover^=1;
tree[id].val=r-l+1-tree[id].val;
return;
}
pushdown(l,r,id);
int mid=(l+r)>>1;
if(L<=mid) insert(L,R,l,mid,id<<1);
if(R>=mid+1) insert(L,R,mid+1,r,id<<1|1);
pushup(id);
}
int main()
{
//freopen("in.txt","r",stdin);
int n,m,i,j,k,e;
ios::sync_with_stdio(false);
while(scanf("%d %d",&n,&m)==2)//cin>>n>>m)
{
for(i=1;i<=n;i++)
{
head[i]=0;
edge[i].next=0;
}
int en=1;
for(i=2;i<=n;i++)
{
scanf("%d",&k);//cin>>k;
edge[en].v=i;
edge[en].next=head[k];
head[k]=en++;
}
cur=0;
dfs(1);
build(1,n,1);
char o;
while(m--)
{
scanf("%*c %c %d",&o,&k);//cin>>o>>k;
if(o=='o') insert(h[k].a,h[k].b,1,n,1);
else printf("%d\n",answer(h[k].a,h[k].b,1,n,1));//cout<<answer(h[k].a,h[k].b,root,0)<<endl;
//for(i=1;i<=n;i++) cout<<h[i].a<<" "<<h[i].b<<endl;
}
puts("");
}
return 0;
}