#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int res=0;
	bool zf=0;
	char c;
	while(((c=getchar())<'0'||c>'9')&&c!='-');
	if(c=='-')zf=1;
	else res=c-'0';
	while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0';
	if(zf)return -res;
	return res;
}
const int maxn=4e5+5,P=1e9+7;
int a[maxn];
int jc[maxn],inv[maxn];
inline int c(int x,int y){
	if(x<y){
		return 0;
	} 
	y=min(y,x-y);
	if(!y){
		return 1;
	} 
	return x;
}
int C(int x,int y){
	if(!y){
		return 1;	
	}
	return C(x/3,y/3)*c(x%3,y%3)%3;
}
signed main(){
	int n=read();
	string s;cin>>s;
	for(register int i=0;i<n;++i){
		if(s[i]=='R'){
			a[i+1]=0;
		}
		else if(s[i]=='W'){
			a[i+1]=1;
		}
		else{
			a[i+1]=2;
		}
	}
	if(!(n&1)){
		for(register int i=1;i<n;++i){
			if(a[i]!=a[i+1]){
				a[i]=3-a[i]-a[i+1];
			}
		}
		--n;
	}
	int A=0;
	for(register int i=1;i<=n;++i){
		A=(A+a[i]*C(n-1,i-1))%3;
	}
	if(A==0){
		puts("R");
	}
	else if(A==1){
		puts("W");
	}
	else{
		puts("B");
	}
	return 0;
}
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include<iomanip>

using namespace std;
using ll = long long;
using ULL = unsigned long long;
using pll = std::pair<ll, ll>;
using vi = std::vector<int>;
using vl = std::vector<ll>;
using vb = std::vector<bool>;
using db = double;
using vdb = std::vector<db>;
using qlg= std::priority_queue<ll, vl, std::greater<ll> > ; //ascending
using qll= std::priority_queue<ll, vl, std::less<ll> > ; // descending
using qdg= std::priority_queue<db, vdb, std::greater<db> > ; //ascending
using qdl= std::priority_queue<db, vdb, std::less<db> > ; // descending
template<class T>
using vv = std::vector<std::vector<T> >;


#define REPL(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FORL(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FORL(i, 0, n)

#define MREP(i, n) for (ll i= (ll)(n)-1; i>=0; i-- )
#define MFOR(i, a, b) for (ll i = (ll)(b)-1; i >= (ll)(a); i--)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
#define INF pow(10, 10)

ll g1(vl val)
{
    ll Max = 0;
    ll MaxNum=-1;
    ll N =10;
    MFOR(i, 1, N)
    {
        if(val[i]>0)
        {
            MaxNum = i;
            break;
        }
    }
    if(MaxNum==-1)
    {
        // val = 0
        return 0;
    }
    Max = MaxNum;
    val[MaxNum] --;
    MREP(i, N)
    {
        while(val[i]>0)
        {
            Max = Max*10+i;
            val[i] --;
        }
    }
    // cout << "Max:" << Max << endl;
    return Max;
}


ll g2(vl val)
{
    ll Max = 0;
    ll Min = 0;
    ll MinNum=-1;
    ll N =10;

    REP(i, N)
    {
        while(val[i]>0)
        {
            Min = Min*10+i;
            val[i] --;
        }
    }
    // cout << "Min:" << Min << endl;
    return Min;
}

vl make_vals(ll N)
{
    vl vals(10, 0);
    ll Min = N%10;
    vals[Min] ++;
    N/=10;
    while(N >0)
    {
        Min = N%10;
        vals[Min] ++;
        N /= 10;

    }
    return vals;
}

int main(void)
{

    ll  N, K;

    cin >> N >> K;

    vl NowVal = make_vals(N);
    vl anss;




    if(K==0)
    {
        cout << N << endl;
    }
    else
    {
        map<ll, ll> Val_Times;
        ll NowN = N;
        Val_Times[NowN] = 1;
        anss.push_back(N);
        ll Tim = 1;
        ll NextN = g1(NowVal)-g2(NowVal);
        vl NextVal = make_vals(NextN);

        anss.push_back(NextN);
        while(Val_Times[NowN] < K && NextN >0)
        {

            NowVal = NextVal;
            NowN = NextN;

            Val_Times[NextN] = ++Tim;

            // cout << NextN << " " << Tim << endl;
            NextN =g1(NowVal)-g2(NowVal);
            NextVal = make_vals(NextN);
            anss.push_back(NextN);
        }

        if(NextN==0)
        {
            cout << 0 << endl;
        }
        else
        {
            ll Ans = g1(NowVal)-g2(NowVal);
            cout << Ans << endl;
        }
    }





    return 0;
}
