#include <bits/stdc++.h>
using namespace std;

int pre[100001], n, q;
bool book[100001];

int find(int x){
	while (!book[pre[x]]) x = pre[x];
	return pre[x];
}

int main()
{
	while (~scanf("%d%d", &n, &q)){
		if (!n && !q)return 0;
		long long sum = 0;
		memset(book, 0, sizeof book);
		book[1] = true;
		for (int i = 2; i <= n; ++i)scanf("%d", &pre[i]);
		while (q--){
			char ch;
			int num;
			cin >> ch;
			scanf("%d", &num);
			if (ch == 'Q'){
				if (book[num])sum += num;
				else sum += find(num);
			}
			else book[num] = true;
		}
		printf("%lld\n", sum);
	}
}
