class Module
  def tco(name)
    continue = []
    first = true
    arguments = nil

    private_name = "private_" + name.to_s
    alias_method private_name, name
    private private_name

    define_method(name) do |*args|
      if first
        first = false
        while true
          result = send(private_name, *args)
          if result.equal? continue
            args = arguments
          else
            first = true
            return result
          end
        end
      else
        arguments = args
        continue
      end
    end
  end
end


class Solve
  def parent(x)
    return x if $mark[x]
    parent($arr[x])
  end
  tco :parent
end

loop do
  n, q = gets.split.map(&:to_i)
  break if n == 0
  $arr = Array.new(n+1)
  (2..n).each{ |i| $arr[i] = gets.to_i }
  $mark = Array.new(n+1)
  $mark[1] = true
  sum = 0
  qs = []
  q.times do
    qs << gets.split
  end
  s = Solve.new
  qs.each do |cmd, n|
    if cmd == 'M'
      $mark[n.to_i] = true
    else
      sum += s.parent(n.to_i)
    end
  end
  p sum
end