//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
#define FAST_IO ios::sync_with_stdio(0);cin.tie(NULL)
#define all(v) (v).begin(),(v).end()
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long Long;
typedef long double Double;
typedef unsigned long long ULong;
typedef pair<Long, Long> Pair;

const int N = 100;
const Long INF = 1e18;
const Double EPS = 1e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
Long random(Long a, Long b) { return uniform_int_distribution<Long> (a, b) (rng); }

string s[N];
int n;
Long dp[N][2];
bool is_done[N][2];

Long DP(int i, bool was_true) {
  if (i == n) return (was_true) ? 1LL : 0LL;
  if (is_done[i][was_true]) return dp[i][was_true];
  if (s[i] == "AND") {
    if (was_true) {
      dp[i][was_true] = DP(i + 1, true) + DP(i + 1, false);
    } else {
      dp[i][was_true] = 2 * DP(i + 1, false);
    }
  } else {
    if (was_true) {
      dp[i][was_true] = 2 * DP(i + 1, true);
    } else {
      dp[i][was_true] = DP(i + 1, true) + DP(i + 1, false);
    }
  }
  is_done[i][was_true] = true;
  return dp[i][was_true];
}

void Solve(void) {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  Long ans = DP(0, true) + DP(0, false);
  cout << ans << '\n';
}

int main(void) {
  FAST_IO;
  int t = 1;
  //cin >> t;
  while (t--) Solve();
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<ll>> C;
vector<ll> sz;

ll f(ll v){
  sz[v]=1;
  ll r=1;
  vector<ll> p1,p2,p3;
  for(ll nv:C[v]){
    ll b=f(nv);
    if(sz[nv]%2==0 && b<0)p1.push_back(b);
    else if(sz[nv]%2==0 && b>=0)p2.push_back(b);
    else p3.push_back(b);
    sz[v]+=sz[nv];
  }
  for(ll x:p1)r+=x;
  sort(p3.begin(),p3.end());
  ll flg=0;
  for(ll x:p3){
    if(flg%2==0)r+=x;
    else r-=x;
    flg++;
  }
  for(ll x:p2){
    if(flg%2==0)r+=x;
    else r-=x;
  }
  return r;
}

int main(){
  ll n,p;cin>>n;
  C.resize(n);sz.resize(n);
  for(ll i=1;i<n;i++){
    cin>>p;p--;
    C[p].push_back(i);
  }
  cout<<(n+f(0))/2<<endl;
}
