/*
AizuOnline A2170
Title Marked Ancestor
5/20 WA
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
#define NO_OF_NODES 100000
int n,q;
int node[NO_OF_NODES+1];
int mark[NO_OF_NODES+1];
//
int nearest_marked_anscestor(int n)
{
  int a;
  /*
  if(mark[n])
    return(n);
  */
  do {
    a=node[n];
#ifdef DEBUG
    printf("A:%d <=%d\n",a,n);
#endif
    if(mark[a])
      return(a);
    n=a;

  }while(a!=1);
}
void mark_node(int n)
{
  mark[n]=-1;
#ifdef DEBUG
  printf("M:%d\n",n);
#endif
}
main()
{ 
  int i,r,sum,arg;
  char op;

  while(EOF!=scanf("%d %d",&n,&q) && (n||q))
    {
      sum=0;
      for(i=2;i<=n;i++)
	mark[i]=0;
      mark[1]=1;
      for(i=2;i<=n;i++)
	{
	  scanf("%d ",&node[i]);
	}
      for(i=0;i<q;i++)
	{
	  scanf("%c %d\n",&op,&arg);
	  if(op=='M')
	    mark_node(arg);
	  else if(op=='Q')
	    {
	      r= nearest_marked_anscestor(arg);
	      sum += r;
	    }
	}
     
      printf("%d\n",sum);
    }
return(0);
}