#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <queue>
#include <vector>
#define SIZE 100010

typedef struct Node
{
	int father;
	int ancester;
	std::vector<int> childs;
} Node;

Node node[SIZE];

void mark(int num)
{
	std::queue<int> q;
	q.push(num);
	while (!q.empty())
	{
		int n = q.front();
		q.pop();
		if (node[n].ancester == n)
		{
			continue;
		}
		node[n].ancester = num;
		for (std::vector<int>::iterator it = node[n].childs.begin(); it != node[n].childs.end(); ++it)
		{
			q.push(*it);
		}
	}
}

int main()
{
	int count, order_count;
	while (scanf("%d%d", &count, &order_count), !(count == 0 && order_count == 0))
	{
		int sum = 0;
		int father;
		for (int i = 1; i <= count; ++i)
		{
			scanf("%d", &father);
			node[i].father = father;
			node[i].ancester = 1;
			node[father].childs.push_back(i);
			node[i].childs.clear();
		}
		char ch;
		int num;
		while (order_count--)
		{
			scanf("%c %d", &ch, &num);
			getchar();
			if (ch == 'Q')
			{
				sum += node[num].ancester;
			}
			else if (ch == 'M')
			{
				mark(num);
			}
		}
		printf("%d\n", sum);
	}
	return 0;
}