#include <bits/stdc++.h>
const int maxn = 100005;
int par[maxn];
int n,q;
void init()
{
	memset(par,0,sizeof(par));
}

int find(int x)
{
	return par[x] == x ? x : find(par[x]);
}

int main()
{
	char op[2];
	int x;
	while(scanf("%d %d",&n,&q) != EOF && (n || q)){
		init();
		par[1] = 1;
		for(int i = 2;i <= n;i++){
			scanf("%d",&x);
			par[i] = x;
		}
		long long y = 0;
		while(q--){
			scanf("%s",op);
			if(op[0] == 'M'){
				scanf("%d",&x);
				par[x] = x;
			}else if(op[0] == 'Q'){
				scanf("%d",&x);
				y += find(x);
			}
		}
		printf("%lld\n",y);
	}
	return 0;
} 