import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;


void main() {
    while (solve) {};
}

bool solve() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto Q = s[1];
    if (N == 0) return false;

    auto parent = new int[](N);
    auto hld = new HeavyLightDecomposition(N);
    
    foreach (i; 1..N) {
        auto p = readln.chomp.to!int - 1;
        parent[i] = p;
        hld.add_edge(p, i);
    }
    parent[0] = -1;

    
    hld.run;
    int M = hld.subtrees.length.to!int;
    
    auto rbts = new RedBlackTree!(int, "a < b", false)[](M);
    foreach (i; 0..M) rbts[i] = new RedBlackTree!(int, "a < b", false);
    rbts[0].insert(0);
    
    long ans = 0;

    while (Q--) {
        auto q = readln.split;
        auto n = q[1].to!int - 1;
        if (q[0] == "M") {
            int subt = hld.n_subtree[n];
            int i = hld.n_subtree_ind[n];
            rbts[subt].insert(i);
        } else {
            while (n != -1) {
                int subt = hld.n_subtree[n];
                int i = hld.n_subtree_ind[n];
                
                auto lb = rbts[subt].lowerBound(i);
                if (lb.empty) {
                    int subroot = hld.subtrees[subt][0];
                    n = parent[subroot];
                } else {
                    int j = lb.back;
                    ans += hld.subtrees[subt][j] + 1;
                    break;
                }
            }
        }
    }


    ans.writeln;

    return true;
}


class HeavyLightDecomposition {
    int N;
    int[] children;
    int[][] edges;
    int[][] subtrees;
    int[] n_subtree;
    int[] n_subtree_ind;
    int[] subt_parent;

    this (int n) {
        N = n;
        edges = new int[][](N);
        children = new int[](N);
        n_subtree = new int[](N);
        n_subtree_ind = new int[](N);
    }
    
    void run() {
        dfs1(0, -1);
        dfs2(0, -1, -1, true);
    }

    void add_edge(int u, int v) {
        edges[u] ~= v;
        edges[v] ~= u;
    }

    
    int dfs1(int n, int prev) {
        children[n] = 1;
        foreach (m; edges[n]) if (m != prev) children[n] += dfs1(m, n);
        return children[n];
    }
    
    void dfs2(int n, int prev, int prev_subt, bool subroot) {
        int subt;
        if (subroot) {
            subtrees ~= [n];
            subt = subtrees.length.to!int - 1;
            subt_parent ~= prev_subt;
        } else {
            subtrees[prev_subt] ~= n;
            subt = prev_subt;
        }
        n_subtree[n] = subt;
        n_subtree_ind[n] = subtrees[subt].length.to!int - 1;
        
        int maxi = -1;
        int maxv = -1;
        foreach (m; edges[n]) {
            if (m == prev) continue;
            if (children[m] > maxv) maxv = children[m], maxi = m;
        }
        foreach (m; edges[n]) {
            if (m == prev) continue;
            dfs2(m, n, subt, m != maxi);
        }
    }
}

unittest {
    auto hld = new HeavyLightDecomposition(11);
    hld.add_edge(0, 1);
    hld.add_edge(0, 2);
    hld.add_edge(1, 3);
    hld.add_edge(1, 4);
    hld.add_edge(1, 5);
    hld.add_edge(2, 6);
    hld.add_edge(4, 7);
    hld.add_edge(4, 8);
    hld.add_edge(8, 9);
    hld.add_edge(6, 10);
    hld.run;
    hld.subtrees.sort();
    assert(hld.subtrees == [[0, 1, 4, 8, 9], 
                            [2, 6, 10],
                            [3],
                            [5],
                            [7]]);
    hld.subt_parent.writeln;
}