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

int main()
{
    int i;
  

     while(scanf("%d%d",&n,&q)!=EOF)
    {
         long long sum;
        if(!n&&!q)break;
        memset(vis, 0, sizeof(vis));
        for(i=1;i<=n;i++)
        {
            f[i]=i;
        }
        vis[1] = 1;
        sum = 0;
        for(i = 1; i < n; ++i)
            scanf("%d", &f[i +  1]);

         for(i=1;i<=q;i++)
        {
            char ch[20];
            scanf("%s",ch);
            
            if(ch[0]=='Q')
            {
                int t;
                scanf("%d",&t);
                sum += _find(t);
            }
            else{
                 int t;
            scanf("%d",&t);
                vis[t] = 1;
            }
        }
        printf("%lld\n", sum);
    }
}