// Slower C++ solution:
#include <iostream>

#include <string.h>

#include <vector>

#include <queue>

#include <stack>

#include <functional>

#include <algorithm>

using namespace std;



const int MAXN = 100010;

const int MAXM = 100010;

const int INF = 0x3f3f3f3f;

typedef long long LL;

typedef pair<char, int> P;



int N, Q;

int father[MAXN]; // 并查集中的父节点

int parent[MAXN]; // 树中的父节点

int vis[MAXN]; // 结点标记次数

vector<int> e[MAXN]; // 记录边，即树的结构e[i][j]表示i的第j+1孩子

stack<P> st; // 存储操作



void dfs(int i, int f = 1) {

	if (vis[i])

		f = i;

	father[i] = f;

	vector<int> &ei = e[i];

	for (vector<int>::iterator it = ei.begin(); it != ei.end(); ++it) {

		dfs(*it, f);

	}

}



//void Init() {

//	for (int i = 0; i < MAXN; ++i) {

//		father[i] = i;

//	}

//}

int Find(int x) {

	if (father[x] == x)

		return x;

	return father[x] = Find(father[x]);

}



int main(int argc, char const *argv[]) {

#ifdef LOCAL

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif

	while (scanf("%d%d", &N, &Q) != EOF && !(N == 0 && Q == 0)) {

		int i, j, q;

		LL res = 0;

		char opt[5];

		for (i = 1; i <= N; ++i) {

			e[i].clear();

		}

		fill(vis, vis + MAXN, 0);

		vis[1] = 1;

		for (i = 2; i <= N; ++i) {

			scanf("%d", &j);

			e[j].push_back(i);// 结点j的孩子i,用于dfs

			parent[i] = j; // 结点i的父亲j

		}

		for (int i = 0; i < Q; ++i) {

			scanf("%s %d", opt, &j);

			if (opt[0] == 'M') {

				++vis[j];// 结点j标记次数

			}

			st.push(P(opt[0], j));// 将操作入栈，操作名和结点

		}

		dfs(1); // 寻找最近染色祖先

		// 逆序处理操作

		while (!st.empty()) {

			i = st.top().second; // 被操作结点

			if (st.top().first == 'M') { 

				if (--vis[i] == 0) // 直到多余标记结束

					father[i] = Find(parent[i]); // 取消染色

			} else {

				res += Find(i); // 查询操作，返回最近染色祖先

			}

			st.pop(); // 处理下一操作

		}

		printf("%lld\n", res);

	}

	//system("pause");

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 2.810082411229675x):
#include <iostream>

#include <sstream>

#include <cstdio>

#include <algorithm>

#include <cstring>

#include <iomanip>

#include <utility>

#include <string>

#include <cmath>

#include <vector>

#include <bitset>

#include <stack>

#include <queue>

#include <deque>

#include <map>

#include <set>



using namespace std;



typedef long long ll;

typedef unsigned long long ull;

const int dir[9][2] = { 0, 1, 0, -1, 1, 0, -1, 0, 1, 1, 1, -1, -1, 1, -1, -1, 0, 0 };

const ll  ll_inf = 0x7fffffff;

const double PI=acos(-1.0);

template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}

const int inf = 0x3f3f3f;

const int mod = (int) 998244353;

const int Max = (int) 1e5 + 22;

stringstream ss;



/**********************************************Head-----Template****************************************/

bool Finish_read;

template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}

template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}

template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}

template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}



/********************************Head----Temlate**********************************************/



//tools:

//priority_queue <int, vector<int>, greater<int> > Q;

//ios::sync_with_stdio(false);

//freopen("input.txt", "r", stdin);

//ss<<int; ss>>str;



int n, q;

int Fa[Max];

int value[Max];



void Init() {

	Fa[1] = 0;

	memset(value, 0, sizeof(value));

	value[1] = 1;

}



int main() {

	while (~scanf("%d %d", &n, &q) && n+q) {

		Init();

		for (int i = 2; i <= n; ++i) {

			scanf("%d", &Fa[i]);

		}



		ll ans = 0;

		int x;

		char ch[10];

		for (int i = 0; i < q; ++i) {

			scanf("%s %d", ch, &x);

			if (ch[0] == 'Q') {

				while (x) {

					if (value[x]) {

						ans += (ll)x;

						break;

					}

					x = Fa[x];

				}

			}

			else {

				value[x] = 1;

			}

		}



		printf("%lld\n", ans);

	}

	return 0;

}