#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 4e5 + 5;
int C[3][3];
void pascal() {
    for(int i = 0;i < 3;i++) {
        C[i][0] = C[i][i] = 1;
        for(int j = 1;j < i;j++)
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % 3;
    }
}
int ncrLucas(int n, int r, int p) {
    if(r == 0)
        return 1;
    int ni = n % p, ri = r % p;
    return (1ll * ncrLucas(n / p, r / p, p) * C[ni][ri]) % p;
}
int n, a[N];
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    pascal();
    cin >> n;
    for(int i = 0;i < n;i++) {
        char c;
        cin >> c;
        if(c == 'B')
            a[i] = 0;
        else if(c == 'W')
            a[i] = 1;
        else
            a[i] = 2;
    }
    int ans = 0;
    for(int i = 0;i < n;i++)
        ans = (ans + (1ll * ncrLucas(n - 1, i, 3) * a[i]) % 3) % 3;
    if(n % 2 == 0)
        ans = (3 - ans) % 3;
    if(ans == 0)
        cout << 'B';
    else if(ans == 1)
        cout << 'W';
    else
        cout << 'R';
    return 0;
}
#include <vector>
#include <array>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    vector<int> P(n, -1);
    for (int i = 1; i < n; ++i) {
        cin >> P[i];
        --P[i];
    }
    vector<vector<int>> graph(n);
    for (int i = 1; i < n; ++i) {
        graph[P[i]].push_back(i);
    }

    int rt = 0;
    const int INF = 1 << 24;
    vector<int> dp(n, -INF);
    vector<int> sizes(n, 0);

    for (int i = n - 1; i >= 0; --i) {
        int u = i;
        sizes[u] = 1;

        long long res = 1;
        vector<vector<int>> ans(2);
        for (auto v : graph[u]) {
            sizes[u] += sizes[v];
            ans[(sizes[v] * 3) & 1].push_back(dp[v]);
        }
        for (auto& V : ans) {
            sort(V.begin(), V.end());
        }
        for (auto x : ans[0]) {
            if (x < 0) {
                res += x;
            }
        }
        int m = ans[1].size();
        // for (int i = 0, j = m - 1, t = 0; t < m; ++t) {
        //     if (t & 1) {
        //         res -= ans[1][j--];
        //     } else {
        //         res += ans[1][i++];
        //     }
        // }
        for (int j = 0; j < m; ++j) {
            if (j & 1) {
                res -= ans[1][j];
            } else {
                res += ans[1][j];
            }
        }
        if (m & 1) {
            for (auto x : ans[0]) {
                if (x > 0) {
                    res -= x;
                }
            }
        } else {
            for (auto x : ans[0]) {
                if (x > 0) {
                    res += x;
                }
            }
        }
        dp[u] = res;
    }
    assert((n + dp[rt]) % 2 == 0);
    cout << (n + dp[rt]) / 2 << '\n';

    return 0;
}