class Node
    attr_accessor :parent, :rank
    def initialize(n)
        @parent = n
        @rank = 0
    end
end

class UnionFindTree
    attr_accessor :nodes
    def initialize(n)
        @nodes = (0..n).to_a.map { |i| Node.new(i) }
    end
    def find(x, m)
        return x if @nodes[x].parent == x || m[x] > 0
        return @nodes[x].parent = find(@nodes[x].parent, m)
    end
    def unite(a, b, m)
        a = find(a, m)
        b = find(b, m)
        return if a == b
        if @nodes[a].rank < @nodes[b].rank
            @nodes[a].parent = b
        else
            @nodes[b].parent = a
            @nodes[b].rank += 1 if @nodes[a].rank == @nodes[b].rank
        end
    end
    def same?(a, b)
        find(a) == find(b)
    end
end
def dfs(v, k, m, pp, ch)
    k = v if m[v] > 0
    pp[v] = k
    ch[v].each do |c|
        pp = dfs(c,k,m,pp,ch)
    end
    return pp
end
loop do
    n, q = gets.split.map(&:to_i)
    break if n == 0 && q == 0
    p = UnionFindTree.new(n)
    pp = Array.new(n+1,-1)
    ch = Array.new(n+1).map{Array.new}
    m = Array.new(n+1,0)
    m[1] = 1
    (n-1).times do |i|
        temp = gets.to_i
        p.nodes[i+2].parent = temp
        pp[i+2] = temp
        ch[temp].push(i+2)
    end
    qs = q.times.map{gets.split}.map{|t, k| [t,k.to_i]}
    qs.each do |qr|
        if qr[0] == "M"
            m[qr[1]] += 1
        end
    end
    pp = dfs(1,-1,m,pp,ch)
    ans = 0
    qs.reverse.each do |qr|
        case qr[0]
        when "M"
            m[qr[1]] -= 1
            p.unite(qr[1], pp[qr[1]], m) if m[qr[1]] == 0
        when "Q"
            ans += p.find(qr[1], m)
        end
    end
    puts ans
end