#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
//#define int long long
using ll = long long;
template <typename T> struct SegmentTree {
    int n;
    T unit;
    vector<T> dat;
    function<T(T, T)> func;
    SegmentTree(const int N, T unit, function<T(T, T)> func) : unit(unit), func(func) {
        n = 1;
        while (n < N) n *= 2;
        dat.assign(2 * n, unit);
    }
    void update(int k, T a) {
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void add(int a, int b, int x) {
        update(a, query(a, a + 1) + x);
        update(b, query(b, b + 1) - x);
    }
    T getsum(int x) { return query(0, x + 1); }
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return unit;
        if (a <= l && r <= b)
            return dat[k];
        else {
            T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
            return func(vl, vr);
        }
    }
    //[a,b)
    T query(int a, int b) { return _query(a, b, 0, 0, n); }
};

// vector<int> G[100010];
int parent[100010][26];
int par[100010];
int id[100010];
int R[100010];
int depth[100010];
int q = 0;
bool vis[100010];
bool marked[100010];
int idx = 0;
bool DEBUG = false;
void dfs(int n, int pre, vector<vector<int>>& G, int d = 0) {
    // if (q >= 2) cerr << d << endl;
    // if (q >= 2) cerr << n << endl;
    // if (n == 70538 || n == 1708) {
    //     cerr << n << endl;
    //     cerr << G[n].size();
    //     for (auto nxt : G[n]) cerr << nxt << " ";
    //     cerr << endl;
    // }
    assert(n >= 0 && n <= 100000);
    assert(idx <= 100000);
    id[n] = idx;
    idx++;
    // vis[n] = true;
    for (auto nxt : G[n]) {
        assert(nxt != n);
        if (nxt == par[n] || nxt == pre) continue;
        assert(0 < nxt && nxt <= 100000);
        // if (vis[nxt]) continue;
        depth[nxt] = depth[n] + 1;
        par[nxt] = n;
        dfs(nxt, n, G, d + 1);
    }
    R[n] = idx;
}
void init_par(int N) {
    REP(i, N) { parent[i][0] = par[i]; }
    FOR(k, 1, 25) {
        REP(i, N) { parent[i][k] = parent[parent[i][k - 1]][k - 1]; }
    }
}
int kth_parent(int n, int k) {
    for (int i = 20; i >= 0; i--) {
        if (k & (1 << i)) {
            n = parent[n][i];
        }
    }
    return n;
}

bool solve() {
    int N;

    cin >> N;
    // cerr << N << endl;
    assert(N <= 100000);
    if (N == 0) return false;
    // cerr << ++q << endl;
    vector<vector<int>> G;
    G.resize(N + 1);
    REP(i, N + 10) {
        // G[i].clear();
        id[i] = 0;
        marked[i] = false;
        depth[i] = 0;
        R[i] = 0;
        vis[i] = false;
        par[i] = 0;
    }
    int Q;
    cin >> Q;
    N++;

    // if (q >= 1) {
    //     FOR(i, 2, N) {
    //         int v;
    //         cin >> v;
    //     }
    //     while (Q--) {
    //         char c;
    //         int v;
    //         cin >> c >> v;
    //     }
    //     return true;
    // }
    G[0].push_back(1);
    G[1].push_back(0);

    FOR(i, 2, N) {
        int v;
        cin >> v;
        G[i].push_back(v);
        G[v].push_back(i);
    }
    idx = 0;
    // cerr << "init tree... ";
    dfs(0, 0, G);
    // cerr << "dfs done ";
    // REP(i, N) { cerr << id[i] << " " << R[i] << endl; }
    init_par(N);
    // cerr << "done" << endl;
    auto f = [](ll a, ll b) { return a + b; };
    // cerr << "init seg... ";
    SegmentTree<ll> seg(N + 1, 0, f);
    // cerr << "done" << endl;
    seg.add(1, R[1], 1);
    ll ans = 0;
    while (Q--) {
        char sign;
        cin >> sign;
        int v;
        cin >> v;
        if (sign == 'M') {
            if (marked[v]) continue;
            // assert(!marked[v]);
            marked[v] = true;
            seg.add(id[v], R[v], v);
            if (DEBUG) REP(i, N) {
                    cerr << i << " " << seg.getsum(id[i]) << endl;
                }
        } else {
            int ok = 0, ng = depth[v];
            if (DEBUG) {
                cerr << "depth:" << depth[v] << endl;
            }
            ll sum = seg.getsum(id[v]);
            if (DEBUG) {
                cerr << "sum:" << sum << endl;
            }
            while (abs(ok - ng) > 1) {
                int mid = (ok + ng) / 2;
                int p = kth_parent(v, mid);
                ll tmp = seg.getsum(id[p]);
                if (tmp == sum) {
                    ok = mid;
                } else
                    ng = mid;
            }
            if (DEBUG) {
                cerr << kth_parent(v, ok) << endl;
            }
            ans += kth_parent(v, ok);
        }
    }
    // cerr << "finish" << endl;
    cout << ans << endl;
    return true;
}
signed main() {
    while (solve())
        ;
    // solve();
}


Measured memory_bytes: 30528