#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define range(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) range(i,0,b)

struct HeavyLightDecomposition {
    int size;
    vector<vector<int>> g;
    vector<int> parent, subtreeSize, depth;
    vector<int> head, next;
    vector<int> chain, at;
    vector<vector<int>> chains;

    HeavyLightDecomposition(int n_ = 0) : size(n_), g(n_) {}

    void addEdge(int a, int b){
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int goUp(int & v) const {
        return parent[head[v]];
    }

    void decompose(const int root = 0){
        parent.assign(size, 0);
        subtreeSize.assign(size, 0);
        depth.assign(size, -1);
        head.assign(size, 0);
        next.assign(size, -1);
        chain.assign(size, -1);
        at.assign(size, 0);
        static int stk[600010], k = 0;
        stk[k++] = root;
        parent[root] = -1;
        depth[root] = 0;
        while(k){
            const int v = stk[--k];
            if(v >= 0){
                stk[k++] = ~v;
                for(const int ch : g[v]){
                    if(depth[ch] != -1) continue;
                    depth[ch] = depth[v] + 1;
                    parent[ch] = v;
                    stk[k++] = ch;
                }
            } else {
                const int u = ~v;
                subtreeSize[u] = 1;
                int m = 0;
                for(const int ch : g[u]){
                    if(parent[u] == ch) continue;
                    subtreeSize[u] += subtreeSize[ch];
                    if(m < subtreeSize[ch]){
                        m = subtreeSize[ch];
                        next[u] = ch;
                    }
                }
            }
        }

        k = 0;
        stk[k++] = root;
        while(k){
            const int head_ = stk[--k];
            for(const int ch : g[head_]){
                if(parent[head_] == ch) continue;
                stk[k++] = ch;
            }
            if(chain[head_] != -1) continue;
            chains.push_back(vector<int>());
            vector<int> & path = chains.back();
            int cur = head_;
            while(cur != -1){
                path.push_back(cur);
                cur = next[cur];
            }
            for(size_t i = 0; i < path.size(); i++){
                const int v = path[i];
                head[v] = path.front();
                next[v] = i+1 != path.size() ? path[i+1] : -1;
                chain[v] = chains.size() - 1;
                at[v] = i;
            }
        }
    }

    vector<map<int,int>> marks; // -depth, node
    void prepare(){
        marks.assign(chains.size(), {});
    }
    void mark(int v){
        marks[chain[v]][-depth[v]] = v;
    }
    int query(int v){
        while(1){
            auto & ms = marks[chain[v]];
            auto it = ms.lower_bound(-depth[v]);
            if(it != ms.end()) return it->second;
            else v = goUp(v);
        }
    }
};

int n,q;
char qt[100010];
int qv[100010];
HeavyLightDecomposition h;

long long solve(){
    long long ans = 0;
    h.decompose();
    h.prepare();
    h.mark(0);
    rep(i,q){
        if(qt[i] == 'Q') ans += h.query(qv[i]) + 1;
        else h.mark(qv[i]);
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    while(cin >> n >> q && n){
        h = HeavyLightDecomposition(n);
        rep(i,n-1){
            int par;
            cin >> par;
            h.addEdge(par-1,i+1);
        }
        rep(i,q){
            cin >> qt[i] >> qv[i];
            qv[i]--;
        }
        cout << solve() << '\n';
    }
}

Measured memory_bytes: 24304