#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int find(vector<int> &par, int k){
  if(par[k] == k) return k;
  return par[k] = find(par,par[k]);
}

int main(){
  int N, Q;
  while(cin >> N >> Q, N){
    vector<int> par(N);
    for(int i = 0; i < N; ++i) par[i] = i;
    int p[N];
    p[0] = 0;
    for(int i = 1; i < N; ++i){
      cin >> p[i];
      --p[i];
      par[i] = p[i];
    }
    vector< pair<char,int> > Query;
    char c;
    int k, count[N];
    fill(count,count+N,0);
    for(int i = 0; i < Q; ++i){
      cin >> c >> k;
      --k;
      if(c == 'M'){
	par[k] = k;
	++count[k];
      }
      Query.push_back(make_pair(c,k));
    }
    reverse(Query.begin(),Query.end());
    /*
    for(int i = 0; i < N; ++i){
      cout << par[i] << " ";
    }cout << endl;
    */
    long long int ans = 0;
    for(int i = 0; i < Q; ++i){
      c = Query[i].first;
      k = Query[i].second;
      if(c == 'Q'){
	ans += (long long int)find(par,k)+1;
      }else{
	--count[k];
	if(!count[k])
	  par[k] = par[p[k]];
      }
    }
    /*
    for(int i = 0; i < N; ++i){
      cout << par[i] << " ";
    }cout << endl;
    */
    cout << ans << endl;
  }
  return 0;
}