#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<ll>> v(200010);
ll l[200010],r[200010];
ll cnt = 0;

// LCA
// verify: https://atcoder.jp/contests/abc014/submissions/9535352
bool used[200010];
ll depth[200010];
ll par[200010][20];

// 根からの深さと1つ上の親を求める. initの中で使う
// ついでにオイラーツアーもやってる
void dfs(ll p=0,ll d=0){
    l[p]=cnt;
    cnt++;
    used[p] = 1;
    depth[p] = d;
    for(auto i:v[p]){
        if(!used[i]){
            dfs(i,d+1);
            par[i][0] = p;
        }
    }
    r[p]=cnt;
    cnt++;
}

// init(n, root) でダブリングテーブルを作製する
// n: 頂点数
void init(ll n, ll root=0){
    for(ll i=0;i<n;i++){
        used[i]=false;
        for(ll j=0;j<20;j++){
            par[i][j] = -1;
        }
    }
    dfs(root,0);
    for(ll j=1;j<20;j++){
        for(ll i=0;i<n;i++){
            if(par[i][j-1] == -1) continue;
            par[i][j] = par[par[i][j-1]][j-1];
        }
    }
}

//頂点aのd個上の親を求める
ll get_nyaa(ll a,ll d){
    for(ll i=19;i>=0;i--){
        if(d & (1<<i)) a = par[a][i];
    }
    return a;
}

// a,bのLCAを求める
ll lca(ll a,ll b){
    if(depth[a] < depth[b]) swap(a,b);
    ll dif = depth[a] - depth[b];
    for(ll i=19;i>=0;i--){
        if(dif & (1<<i)) a = par[a][i];
    }
    if(a==b) return a;
    for(ll i=19;i>=0;i--){
        if(par[a][i]!=par[b][i]){
            a = par[a][i], b = par[b][i];
        }
    }
    return par[a][0];
}


// Segment Tree
template<class Monoid, class Action> struct SegTree {
    using FuncMonoid = function< Monoid(Monoid, Monoid) >;
    using FuncAction = function< void(Monoid&, Action) >;
    using FuncLazy = function< void(Action&, Action) >;
    FuncMonoid FM;
    FuncAction FA;
    FuncLazy FL;
    Monoid UNITY_MONOID;
    Action UNITY_LAZY;
    ll SIZE, HEIGHT;
    vector<Monoid> dat;
    vector<Action> lazy;

    SegTree() { }
    SegTree(ll n, const FuncMonoid fm, const FuncAction fa, const FuncLazy fl,
            const Monoid &unity_monoid, const Action &unity_lazy)
    : FM(fm), FA(fa), FL(fl), UNITY_MONOID(unity_monoid), UNITY_LAZY(unity_lazy) {
        SIZE = 1; HEIGHT = 0;
        while (SIZE < n) SIZE <<= 1, ++HEIGHT;
        dat.assign(SIZE * 2, UNITY_MONOID);
        lazy.assign(SIZE * 2, UNITY_LAZY);
    }
    void init(ll n, const FuncMonoid fm, const FuncAction fa, const FuncLazy fl,
            const Monoid &unity_monoid, const Action &unity_lazy) {
        FM = fm; FA = fa; FL = fl;
        UNITY_MONOID = unity_monoid; UNITY_LAZY = unity_lazy;
        SIZE = 1; HEIGHT = 0;
        while (SIZE < n) SIZE <<= 1, ++HEIGHT;
        dat.assign(SIZE * 2, UNITY_MONOID);
        lazy.assign(SIZE * 2, UNITY_LAZY);
    }

    /* set, a is 0-indexed */
    void set(ll a, const Monoid &v) { dat[a + SIZE] = v; }
    void build() {
        for (ll k = SIZE - 1; k > 0; --k)
            dat[k] = FM(dat[k*2], dat[k*2+1]);
    }

    /* update [a, b) */
    inline void evaluate(ll k) {
        if (lazy[k] == UNITY_LAZY) return;
        if (k < SIZE) FL(lazy[k*2], lazy[k]), FL(lazy[k*2+1], lazy[k]);
        FA(dat[k], lazy[k]);
        lazy[k] = UNITY_LAZY;
    }
    inline void update(ll a, ll b, const Action &v, ll k, ll l, ll r) {
        evaluate(k);
        if (a <= l && r <= b)  FL(lazy[k], v), evaluate(k);
        else if (a < r && l < b) {
            update(a, b, v, k*2, l, (l+r)>>1), update(a, b, v, k*2+1, (l+r)>>1, r);
            dat[k] = FM(dat[k*2], dat[k*2+1]);
        }
    }
    inline void update(ll a, ll b, const Action &v) { update(a, b, v, 1, 0, SIZE); }

    /* get [a, b) */
    inline Monoid get(ll a, ll b, ll k, ll l, ll r) {
        evaluate(k);
        if (a <= l && r <= b)
            return dat[k];
        else if (a < r && l < b)
            return FM(get(a, b, k*2, l, (l+r)>>1), get(a, b, k*2+1, (l+r)>>1, r));
        else
            return UNITY_MONOID;
    }
    inline Monoid get(ll a, ll b) { return get(a, b, 1, 0, SIZE); }
    inline Monoid operator [] (ll a) { return get(a, a+1); }
    /* debug */
    void prll() {
        for (ll i = 0; i < SIZE; ++i) { cout << (*this)[i]; if (i != SIZE) cout << ","; }
        cout << endl;
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    //ifstream cin("in.txt");
    ll n,q;
    while(cin>>n>>q){
        if(n==0) break;
        v = vector<vector<ll>>(200010);
        cnt = 0;
        for(ll i=1;i<n;i++){
            ll a;
            cin>>a;
            a--;
            v[i].push_back(a);
            v[a].push_back(i);
        }
        auto fm = [](ll a, ll b) { return max(a, b); };
        auto fa = [](ll &a, ll d) { a = max(a, d); };
        auto fl = [](ll &d, ll e) { d = max(d, e); };
        init(n,0);
        ll ans = 0;
        SegTree<ll, ll> seg(2*n, fm, fa, fl, 0, 0);
        while(q--){
            char c;
            ll a; 
            cin>>c>>a;
            a--;
            if(c=='M'){
                seg.update(l[a],r[a]+1,depth[a]);
            }
            if(c=='Q'){
                ll ret = get_nyaa(a,depth[a]-seg.get(l[a],l[a]+1))+1;
                ans += ret;
            }
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 43556