#include<stdio.h>
#include<string.h>
int A[100010],B[100010];
int n,q,i,j;
int Find(int a)
{    
	if(B[a]==1)
	return a;
	else return Find(A[a]);
}
int main(){
	while(scanf("%d%d",&n,&q)&&(n!=0||q!=0))
	{
		memset(B,0,sizeof(B));
		long long int sum=0;
		B[1]=1;
		for(i=2;i<=n;i++)
		{
			int a;
			scanf("%d",&a);
			A[i]=a;
		}	
		char ss[5];
		while(q--)
		{
			scanf("%s",ss);
			if(ss[0]=='Q')
			{
				int b;
				scanf("%d",&b);
				sum+=(long long)Find(b);
			}
			else if(ss[0]=='M')
			{
				int b;
				scanf("%d",&b);
				B[b]=1;
			}
		}
		printf("%lld\n",sum);
	}
	
}

