#include<stdio.h>
#define maxn 100005
int n,m;
int f[maxn];
char vis[maxn];
int _find(int x)
{
    if(vis[x])
        return x;
    else return _find(f[x]);
}
int main()
{

    
    int i;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        if(!n&&!m)break;
        long long sum=0;
        for(i=1;i<=n;i++)
        {
            f[i]=i;
        }
        memset(vis,0,sizeof(vis));
        vis[1]=1;
        for(i=1;i<n;i++)
        {
            int ch;
            scanf("%d",&ch);
            f[i+1]=ch;
        }
        for(i=1;i<=m;i++)
        {
            char ch[20];
            scanf("%s",ch);
            if(ch[0]=='Q')
            {
                int t;
                scanf("%d",&t);
縲??縲??縲??縲??縲??縲??for(; !vis[t]; t = f[t]) ;
                sum+=t;
            }
            else
            {
                int t;
                scanf("%d",&t);
                vis[t]=1;

            }
        }
        printf("%lld\n",sum);

    }
    return 0;

}