// AOJ 2170: Marked Ancestor
// 2018.1.2 bal4u@uu

#include <stdio.h>

int p[100003];

//#define getchar_unlocked()  getchar()
int in()
{
	int n, c;

//	while ((c = getchar_unlocked()) < '0');
	c = getchar_unlocked();
	n = 0;
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int find(int v)
{
	if (v == p[v]) return v;
	return find(p[v]);
}

int main()
{
	int N, Q, i, cmd, v;
	long long ans;

	while (N = in()) {
		Q = in();
		p[1] = 1; for (i = 2; i <= N; i++) p[i] = in();

		ans = 0;
		for (i = 0; i < Q; i++) {
			cmd = getchar_unlocked(); getchar_unlocked();
			v = in();
			if (cmd == 'M') p[v] = v;
			else ans += find(v);
		}
		printf("%lld\n", ans);
	}
	return 0;
}
