#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

const ll D = 20;
ll p[D][100000];

ll s[100000], t[100000];
vector<ll> E[100000];

void dfs(ll v, ll &d) {
  s[v] = d++;
  for(ll u : E[v]) dfs(u, d);
  t[v] = d;
}

template<typename T, typename E> class LazySegmentTree {
public:
  typedef function<T (T, T)> Operator;
  typedef function<E (E, E)> Merge;
  typedef function<T (T, E)> Apply;
  typedef function<E (E, ll)> Product;

  vector<T> data;
  vector<E> lazy;
  ll n;        // size of elements (2^x alignment)
  T e;         // identity of monoid
  Operator op; // binary operator of monoid
  E d;         // identity of effect
  Merge merge; // merge effects
  Apply apply; // apply effect to monoid
  Product p;   // calculate effect * n

  // construction with size of elements
  LazySegmentTree(ll _n, T e, Operator op, E d, Merge merge, Apply apply, Product p):
    e(e), op(op), d(d), merge(merge), apply(apply), p(p) {
    for(n = 1; n < _n; n *= 2);
    data.resize(n * 2 - 1, e);
    lazy.resize(n * 2 - 1, d);
  }

  // construction with initial values
  LazySegmentTree(const vector<T> &vec, T e, Operator op, E d, Merge merge, Apply apply, Product p):
    e(e), op(op), d(d), merge(merge), apply(apply), p(p) {
    for(n = 1; n < (ll) vec.size(); n *= 2);
    data.resize(n * 2 - 1, e);
    lazy.resize(n * 2 - 1, d);
    REP(i, 0, vec.size()) data[i + n - 1] = vec[i];
    for(ll i = n - 2; i >= 0; i--) data[i] = op(data[i * 2 + 1], data[i * 2 + 2]);
  }

  // evaluate lazy update
  void eval(ll k, ll l, ll r) {
    if(r - l > 1) {
      lazy[k * 2 + 1] = merge(lazy[k * 2 + 1], lazy[k]);
      lazy[k * 2 + 2] = merge(lazy[k * 2 + 2], lazy[k]);
    }
    data[k] = apply(data[k], p(lazy[k], r - l));
    lazy[k] = d;
  }

  // query for [a, b)
  T query(ll a, ll b) { return query(a, b, 0, 0, n); }
  T query(ll a, ll b, ll k, ll l, ll r) {
    eval(k, l, r);
    if(r <= a || b <= l) return e;
    if(a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  // update values of [a, b)
  T update(ll a, ll b, E x) { return update(a, b, x, 0, 0, n); }
  T update(ll a, ll b, E x, ll k, ll l, ll r) {
    eval(k, l, r);
    if(r <= a || b <= l) return data[k];
    if(a <= l && r <= b) {
      lazy[k] = merge(lazy[k], x);
      return apply(data[k], p(lazy[k], r - l));
    }
    T vl = update(a, b, x, k * 2 + 1, l, (l + r) / 2);
    T vr = update(a, b, x, k * 2 + 2, (l + r) / 2, r);
    return data[k] = op(vl, vr);
  }
};

int main(void) {
  ll N, Q;
  while(cin >> N >> Q) {
    if(N == 0 && Q == 0) break;
    REP(i, 0, 100000) E[i].clear();
    REP(i, 1, N) {
      cin >> p[0][i], p[0][i]--;
      E[p[0][i]].push_back(i);
    }

    REP(i, 0, D - 1) REP(j, 0, N) {
      if(p[i][j] != -1) p[i + 1][j] = p[i][p[i][j]];
      else p[i + 1][j] = -1;
    }

    ll d = 0;
    dfs(0, d);

    LazySegmentTree<ll, ll>::Operator op = [](ll a, ll b) { return a + b; };
    LazySegmentTree<ll, ll>::Merge merge = [](ll x, ll y) { return x + y; };
    LazySegmentTree<ll, ll>::Apply apply = [](ll a, ll x) { return a + x; };
    LazySegmentTree<ll, ll>::Product _p = [](ll x, ll n) { return x; };
    LazySegmentTree<ll, ll> segtree(N, 0, op, 0, merge, apply, _p);

    ll ans = 0;
    REP(i, 0, Q) {
      string I;
      ll v;
      cin >> I >> v; v--;

      if(I == "Q") {
        ll u = v;
        for(ll i = D - 1; i >= 0; i--) {
          if(p[i][u] != -1 && segtree.query(s[u], s[u] + 1) == segtree.query(s[p[i][u]], s[p[i][u]] + 1)) {
            u = p[i][u];
          }
        }
        ans += u + 1;
      }
      if(I == "M") {
        segtree.update(s[v], t[v], 1);
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 36436