// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
int ncr(int n, int r){
    if(r > n || r < 0)
        return 0;
    if(n < 3){
        int ans = 1;
        for(int i = 1; i <= r; i++)
            ans *= (n - i + 1);
        for(int i = 1; i <= r; i++)
            ans /= (i );
        return ans;
    }

    return ncr(n/3, r/3) * ncr(n%3, r%3); // Lucas's theorem
}
void solve(){
    int n;
    string str;
    cin>>n>>str;
    string test = "BWR";
    int arr[n];
    for(int i = 0; i < n; i++)
        arr[i] = test.find(str[i]);

    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += ncr(n-1, i)*arr[i];
        ans %= 3;
    }
    if(n%2 == 0){
        ans *= -1;
        ans += 3;
    }
    ans %= 3;
    cout<<test[ans];
}
signed main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}
/*
 ALLAH is Almighty....
*/
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pi                                acos( -1.0 )
#define rep( i, a, n )                    for ( ll i = a; i < n; i++ )
#define per( i, a, n )                    for ( ll i = n - 1; i >= a; i-- )
#define ll                                long long
#define all( x )                          ( x ).begin(), ( x ).end()

typedef tree < ll, null_type, less < ll >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

const ll N = 2e5 + 9;
const ll MOD = 1e9 + 7;


ll n, ans, T;
ll A[ 42 ];
vector < ll > part1, part2;


void solve( int t )
{
      cin >> n >> T;

      rep( i, 0, n ) {
            cin >> A[ i ];
      }

      ll num = 1 << ( n / 2 );

      while ( num-- ) {
            ll sum = 0;
            rep( i, 0, 22 ) {
                  if ( ( 1 << i ) & num ) {
                        sum += A[ i ];
                  }
            }
            part1.push_back( sum );
      }

      num = 1 << ( n - n / 2 );

      while ( num-- ) {
            ll sum = 0;
            rep( i, 0, 22 ) {
                  if ( ( 1 << i ) & num ) {
                        sum += A[ i + n / 2 ];
                  }
            }
            part2.push_back( sum );
      }

      part1.push_back( 0 );
      part2.push_back( 0 );
      part2.push_back( 1e18 );
      sort( all( part2 ) );

      rep( i, 0, part1.size() ) {
            ll res = part1[ i ];
            if ( res > T ) {
                  continue;
            }
            ll idx = upper_bound( all( part2 ), T - res ) - part2.begin();
            res += part2[ idx - 1 ];
            ans = max( ans, res );
      }

      cout << ans;
}

int main()
{
      ios_base::sync_with_stdio( false );
      cin.tie( NULL );
      cout.tie( NULL );
      cout << setprecision( 12 );

      int t = 1;
      //cin >> t;

      for ( int i = 1; i <= t; ++i )  {
            solve( i + 1 );
      }

      return 0;
}
