def solve():

    import sys

    file_input = sys.stdin

    while True:

        N, Q = list(map(int, file_input.readline().split()))

        if N == 0:

            break

        parent = [None, None]

        parent += [int(file_input.readline()) for _ in range(N - 1)]

        unmarked = [True] * (N + 1)

        unmarked[1] = False

        ans = 0

        for _ in range(Q):

            line = file_input.readline()

            v = int(line[2:])

            if line[0] == 'M':

                unmarked[v] = False

            else:

                while unmarked[v]:

                    v = parent[v]

                ans += v

        print(ans)



solve()

class UnionFind:

    def __init__(self, size):

        self.table = [None] * size



    def find(self, x):

        if self.table[x] == None:

            return x

        else:

            # compression of the path

            self.table[x] = self.find(self.table[x])

            return self.table[x]

    

    def union(self, parent, child):

        p_root = self.find(parent)

        c_root = self.find(child)

        if p_root != c_root:

            self.table[c_root] = p_root

        

def solve():

    import sys

    input_lines = sys.stdin.readlines()

    while True:

        N, Q = list(map(int, input_lines[0].split()))

        if N == 0:

            break

        

        unmarked = [True] * (N + 1)

        unmarked[1] = False

        operation = []

        for o in input_lines[N:N+Q]:

            mq, v = o.split()

            v = int(v)

            if mq == 'M':

                if unmarked[v]:

                    unmarked[v] = False

                    operation.append((mq, v))

            else:

                operation.append((mq, v))

        

        uf = UnionFind(N + 1)

        parent = [None, 1] + list(map(int, input_lines[1:N]))

        for v, p in enumerate(parent[2:], start=2):

            if unmarked[v]:

                uf.union(p, v)

        

        ans = 0

        for o, v in reversed(operation):

            if o == 'M':

                uf.union(parent[v], v)

            else:

                ans += uf.find(v)

        

        print(ans)

        

        del input_lines[:N+Q]



solve()

def solve():
    import sys

    file_input = sys.stdin
    while True:
        N, Q = list(map(int, file_input.readline().split()))
        if N == 0:
            break
        parent = [None, None]
        parent += [int(file_input.readline()) for _ in range(N - 1)]
        unmarked = [True] * (N + 1)
        unmarked[1] = False
        ans = 0
        for _ in range(Q):
            line = file_input.readline()
            v = int(line[2:])
            if line[0] == "M":
                unmarked[v] = False
            else:
                while unmarked[v]:
                    v = parent[v]
                ans += v
        print(ans)


solve()

class UnionFind:
    def __init__(self, size):
        self.table = [None] * size

    def find(self, x):
        if self.table[x] == None:
            return x
        else:
            # compression of the path
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, parent, child):
        p_root = self.find(parent)
        c_root = self.find(child)
        if p_root != c_root:
            self.table[c_root] = p_root


def solve():
    import sys

    input_lines = sys.stdin.readlines()
    while True:
        N, Q = list(map(int, input_lines[0].split()))
        if N == 0:
            break
        unmarked = [True] * (N + 1)
        unmarked[1] = False
        operation = []
        for o in input_lines[N : N + Q]:
            mq, v = o.split()
            v = int(v)
            if mq == "M":
                if unmarked[v]:
                    unmarked[v] = False
                    operation.append((mq, v))
            else:
                operation.append((mq, v))
        uf = UnionFind(N + 1)
        parent = [None, 1] + list(map(int, input_lines[1:N]))
        for v, p in enumerate(parent[2:], start=2):
            if unmarked[v]:
                uf.union(p, v)
        ans = 0
        for o, v in reversed(operation):
            if o == "M":
                uf.union(parent[v], v)
            else:
                ans += uf.find(v)
        print(ans)
        del input_lines[: N + Q]


solve()

+class UnionFind: +    def __init__(self, size): +        self.table = [None] * size + +    def find(self, x): +        if self.table[x] == None: +            return x +        else: +            # compression of the path +            self.table[x] = self.find(self.table[x]) +            return self.table[x] + +    def union(self, parent, child): +        p_root = self.find(parent) +        c_root = self.find(child) +        if p_root != c_root: +            self.table[c_root] = p_root + + -    file_input = sys.stdin +    input_lines = sys.stdin.readlines() -        N, Q = list(map(int, file_input.readline().split())) +        N, Q = list(map(int, input_lines[0].split())) -        parent = [None, None] -        parent += [int(file_input.readline()) for _ in range(N - 1)] +        operation = [] +        for o in input_lines[N : N + Q]: +            mq, v = o.split() +            v = int(v) +            if mq == "M": +                if unmarked[v]: +                    unmarked[v] = False +                    operation.append((mq, v)) +            else: +                operation.append((mq, v)) +        uf = UnionFind(N + 1) +        parent = [None, 1] + list(map(int, input_lines[1:N])) +        for v, p in enumerate(parent[2:], start=2): +            if unmarked[v]: +                uf.union(p, v) -        for _ in range(Q): -            line = file_input.readline() -            v = int(line[2:]) -            if line[0] == "M": -                unmarked[v] = False +        for o, v in reversed(operation): +            if o == "M": +                uf.union(parent[v], v) -                while unmarked[v]: -                    v = parent[v] -                ans += v +                ans += uf.find(v) +        del input_lines[: N + Q]