#include<stdio.h>
#include<string>
#include<cstring>
using namespace std;
const int num = 1e5+1;
int n,q,ask[num][2],time[num]={},askl=0;
int father[num];
bool mark[num]={};
long long getF(int t)
{
    if(mark[t]&&time[t]<=ask[askl][1])
        return (long long)t;
    return (long long)(father[t]=getF(father[t]));
}
int main()
{
    scanf("%d%d",&n,&q);
    char c;
    int x,i,j,fax,t;
    long long ans=0;
    for(i=2;i<=n;++i)
        scanf("%d",&father[i]);
    getchar();
    bool flag=false;
    time[1]=0;
    mark[1]=true;
    while(scanf("%c",&c)&&c!='0'){
        scanf("%d",&x);
        if(c=='M'){
            if(!flag){
                ++t;
                flag=true;
            }
            mark[x]=true;
            time[x]=t;
        }
        else{
            flag=false;
            ++askl;
            ask[askl][0]=x;
            ask[askl][1]=t;
        }
        getchar();
    }
    while(askl>0){
        ans+=getF(ask[askl][0]);
        --askl;
    }
    printf("%lld\n",ans);
    return 0;
}

