#include<stdio.h>
typedef long long ll;
int pre[1000000];
int finds(int x)
{
    return x == pre[x] ? x : finds(pre[x]);//注意与 pre[x] = finds(pre[x]);的区别。
}
int main()
{
    int Q, N;
    while (~scanf("%d%d", &Q, &N) && Q && N) {
        pre[1] = 1;
        for (int i = 2; i <= Q; i++) {
            scanf("%d", &pre[i]);
        }
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            char c;
            int x;
            scanf(" %c%d", &c, &x);
            if (c == 'Q') ans += finds(x);
            else pre[x] = x;
        }
        printf("%lld\n", ans);
    }
    return 0;}
