#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

typedef long long ll;
typedef pair <int,int> ii;

int n;
vector <char> s;
vector <char> temp;
vector <int> pre;

int pt;

int main() {
	for(int j=1;j<=1200000;j*=3)
	{
		pre.pb(j);
	}
	
	pt=pre.size()-1;
	
	scanf("%d ",&n);
	
	for(int i=0;i<n;i++)
	{
		s.pb(0);
		scanf("%c",&s[i]);
	}
	
	while(n>1)
	{
		while(n<pre[pt]+1)
		{
			pt--;
		}
		
		for(int i=0;i+pre[pt]<n;i++)
		{
			if(s[i]!=s[pre[pt]+i])
			{
				temp.pb('W'+'B'+'R'-s[i]-s[pre[pt]+i]);
			}
			
			else
			{
				temp.pb(s[i]);
			}
		}
		
		s=temp;
		temp.clear();
		n=s.size();
	}
	
	printf("%c",s[0]);
	
	return 0;
}
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() 
{
	int n, m, k;
	cin >> n >> m >> k;
	long int total = 0;
	rep(i, 0, n - 1) {
		int x;
		cin >> x;
		total += x;
	}
	int ans;
	ans = k * n - total;
	if (ans < 0)cout << 0;
	else if (ans > m)cout << -1;
	else cout << ans;
}