#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define mem(name,value) memset(name,value,sizeof(name))
#define loop(i,from,to) for(int i=from;i<to;i++)
#define pb push_back
using namespace std;
typedef long long ll;

const int maxn=100000+5;
int par[maxn*2],n,q,ans,v;
char op;
bool marked[maxn];

void init(int N)
{
    loop(i,0,N)
        par[i]=i;
}

int main()
{
    while(scanf("%d%d",&n,&q)!=EOF){
        if(n==0 && q==0) break;
        init(n+1);
        mem(marked,false);
        marked[1]=true;
        ans=0;
        loop(i,2,n+1){
            scanf("%d",&v);
            par[i]=v;
        }
        loop(i,0,q){
            getchar();
            scanf("%c%d",&op,&v);
            if(op=='M') marked[v]=true;
            if(op=='Q'){
                do v=par[v];
                while(!marked[v]);
                ans+=v;
            }
        }
        cout<<ans<<endl;
    }
}