def root(x)
  if $Tree[x] == x
    x
  else
    $Tree[x] = root($Tree[x])
  end
end

# $Tree[1] がroot
def initTree
  $Tree = Array.new(100001)
  0.upto(100001) do |i|
    $Tree[i] = i
  end
end

# 1 if marked, otherwise 0
def initMarked
  $Marked = Array.new(100001, 0)
  $Marked[1] = 1
end

def mark(x)
  $Marked[x] = 1
end

def printMarked(x)
  $Marked[$Tree[x]] == 1 ? $Tree[x] : printMarked($Tree[x])
end

if __FILE__ == $0
  loop do
    n, q = gets.split.map(&:to_i)
    break if n.zero? && q.zero?

    initTree
    initMarked
    count = 0

    (n-1).times do |i|
      m = gets.to_i
      $Tree[i+2] = m
    end

    q.times do |i|
      op, m = gets.chomp.split
      m = m.to_i
      op == "M" ? mark(m) : count += printMarked(m)
    end
    p count
  end
end