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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; 
using vi = vector<int>; using vvi = vector<vi>;
vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args> 
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
void printbits(ll mask, ll n) { rep(i, n) { cout << !!(mask & (1ll << i)); } cout << endl; }
#define ldout fixed << setprecision(40) 

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

// ?????????????????????????!!!!!!!!!!!!!
template <class T>
struct fenwick_tree {
    /**********************/
    // ?????????????????
    /**********************/
    T T0 = 0;
    T op(T a, T b) { return a + b; }
    /**********************/
    // ????????????I?????????
    /**********************/

    // x?????f???[???^???\?????????Bop=+, invop=1, T=int, T0=0????????
    // i???????????E???Y?????????????????????????????s[i]?????????????Ax[i] = s[i]???????????a (??????: i=5, s[i]="45", x[i]=9)
    // 0123456789ABCDEF
    // 01234567--------
    // 0123----89AB----
    // 01--23--89--CD--
    // 0-2-4-6-8-A-C-E-
    int n_org;
    vector<T> x;
    fenwick_tree(int n_)  { 
        n_org = n_;
        int n = 1; while (n <= n_) n *= 2;
        x = vector<T>(n, T0);
    }
    // O(log n)
    T query(int j) {
        T S = T0;
        for (j; j >= 0; j = (j & (j + 1)) - 1)  // j?????AC->B->7?????J??????????????B0????????????C??????J???o???[????????????????????????????????????Y?????????????????
            S = op(S, x[j]); 
        return S;
    }
    // O(log n)
    void update(int k, T a) {
        for (; k < x.size(); k |= k+1) // k?????AC->D->F?????J??????????????BC??????J???o???[????????????????????????S?????????????
            x[k] = op(x[k], a); 
    }
    // O(1)
    // ????????????x[i]?????A???N???Z???X????????????
    T access(int k) {
        return query(k) - (k ? query(k-1) : 0);
    }
    void print(void) {
        for (int i = 0; i < n_org; i++) 
            cout << access(i) << " ";
        cout << endl;
    }
    void print_raw(void) {
        for (int i = 0; i < x.size(); i++) 
            cout << x[i] << " ";
        cout << endl;
    }
};

// ?????I??????
//
// ???\???zO(n): ???I???C?????????[???c???A???[, ????????????????, ???c??????_???u???????????????O
//
// LCA O(log n)
// ?????????_?????????????????? O(log n)
// ?????????_?????????????????????p???X?????????T?????? O(log n)
class Tree {
public:
    static const int MAXLOGV = 25;
    vector<vector<int> > m_edges; // m_edges[i][j]??????????????????: i->j??????????????????????
    int vn; // ?????????_????????, vn<2^MAXLOGV
    int root; // ?????????m???[???h??????????

    vector<vector<int>> parent; // parent[i][j]: j??????i^2?????????e???Bj=0???????????????e???B
    vector<int> depth; // depth[i]: ?????????_i??????????????????????[??????, ????????????0

    vector<int> euler; // ??????????????????n????????I???C?????????[???c???A???[???A????????????vn*2
    vector<int> f; // f[i] = euler??????i?????????o??????????????1????????????u, ????????????vn
    vector<int> s; // f[i] = euler??????i?????????o??????????????2????????????u, ????????????vn

    /*********/
    // ???\???z
    /*********/
    Tree(int vn, int root) : vn(vn), root(root) {
        parent.resize(MAXLOGV);
        m_edges.resize(vn);
        for (int i = 0; i < MAXLOGV; i++) 
            parent[i].resize(vn);
        depth.resize(vn);
    }

    // ????????????????\???z
    void unite(int u, int v) {
        m_edges[u].push_back(v);
        m_edges[v].push_back(u);
    }

    // root??????????????[???????????e??????m???F???B
    // unite?????????I??????????????????????????????????????????????????B
    void init() {
        euler.clear(); euler.reserve(2 * vn);
        f.clear(); f.resize(vn);
        s.clear(); s.resize(vn);
        dfs(root, -1, 0);
        for (int k = 0; k+1 < MAXLOGV; k++) // 2^k??????c?????????v???Z
            for (int v = 0; v < vn; v++) 
                if (parent[k][v] < 0) 
                    parent[k+1][v] = -1; // 2^k????????e?????????????????´?????????????????A2^(k+1)????????e?????????????????????´??????????????????
                else 
                    parent[k+1][v] = parent[k][parent[k][v]]; // 2^(k+1)????????e?????A2^k????????e??????2^k????????e???B
    }

    // 1?????e?????[???????????I???C?????????[???c???A???[??????\???z
    void dfs(int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        f[v]=euler.size();
        euler.push_back(v);
        for (int next : m_edges[v]) 
            if (next != p)
                dfs(next, v, d+1);
        s[v]=euler.size();
        euler.push_back(v);
    }

    /*********/
    // ???N???G??????
    /*********/
    // ?????????_u, v????????????????????????c
    //
    // O(log n)
    int lca(int u, int v) const {
        if (depth[u] > depth[v]) swap(u, v); // u?????????????????????????????????????
        for (int k = 0; k < MAXLOGV; k++)    // v??????u?????????????????[?????????????k??????
            if ((depth[v] - depth[u])>>k & 1) 
                v = parent[k][v];
        if (u == v) return u;
        for (int k = MAXLOGV-1; k >= 0; k--) { // ???s?????????????????????????M?????????M???????????k??????
            if (parent[k][u] == parent[k][v]) // ???s??????????????
                continue; 
            u = parent[k][u];
            v = parent[k][v];
        }
        return parent[0][u];
    }

    // u??????v?????????????????????????
    // ?????????????????G???b???W?????d?????????????????A???J??????????????`
    //
    // O(log n)
    int dist(int u, int v) const {
        int p = lca(u, v);
        return (depth[u]-depth[p]) + (depth[v]-depth[p]);
    }

    // [root, v]?????????????????Af???????????????????????????????????m???[???h???????????
    // 1????????????????????????????????????-1??????????????B
    //
    // O(log n)
    int binary_search(int v, function<bool(int)> f) const {
        for(int j = MAXLOGV - 1; j >= 0;j--) 
            if(parent[j][v] != -1 && f(parent[j][v]))
                v = parent[j][v];
        return f(v) ? v : -1;
    }

    // ???????\?????????`??????
    void print_dfs(int v, int p) const {
        for (int i = 0; i < depth[v]; i++)
            cout << " ";
        cout << v << endl;
        for (int next : m_edges[v]) if (next != p) 
            print_dfs(next, v);
    }
    void print(void) const {
        print_dfs(root, -1);
    }
};

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);

    ll n, q; 
    while (cin >> n >> q && n && q) {
        Tree t(n, 0);
        rep(i, n-1) {
            ll tmp; cin >> tmp;
            t.unite(i+1, tmp-1); 
        }
        t.init();

        fenwick_tree<ll> ft(n*2);
        ft.update(t.f[0], 1);
        ft.update(t.s[0], -1);

        ll ret = 0;
        rep(_, q) {
            char c; ll v; cin >> c >> v; v--;
            if (c == 'M') {
                if (ft.access(t.f[v]))
                    continue;
                ft.update(t.f[v], 1);
                ft.update(t.s[v], -1);
            } else {
                ll marked_num = ft.query(t.f[v]);
                ret += t.binary_search(v, [&](ll x){ return ft.query(t.f[x]) == marked_num; }) + 1; 
            }
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 25744