#include<bits/stdc++.h>
using namespace std;
int n,k,a[110],b[110];char c[110];
int sol(int a,int b){if(a>b)swap(a,b);if(a==0&&b==2)return a;return b;}
int main()
{
	scanf("%d%d%s",&n,&k,c+1);
	for(int i=1;i<=n;i++)
	{
		if(c[i]=='R')a[i]=0;
		if(c[i]=='P')a[i]=1;
		if(c[i]=='S')a[i]=2;
	}
	while(k--)
	{
		if(n&1)
		{
			int m=0;
			for(int i=1;i<=n/2;i++)b[++m]=sol(a[i*2-1],a[i*2]);b[++m]=sol(a[n],a[1]);
			for(int i=1;i<=n/2;i++)b[++m]=sol(a[i*2],a[i*2+1]);
		}
		else
		{
			for(int i=1;i<=n/2;i++)b[i]=sol(a[i*2-1],a[i*2]);
			n>>=1; 
		}
		for(int i=1;i<=n;i++)a[i]=b[i];
	}
	if(a[1]==0)cout<<'R';
	if(a[1]==1)cout<<'P';
	if(a[1]==2)cout<<'S';
	return 0;
}
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dy[4]={ -1,0,1,0 };
const int dx[4]={ 0,-1,0,1 };

int N;
ll X;
ll A[51];

unordered_map<ll,ll> dp[51];
ll solve(int n, ll k){
    if(n == -1) return (k == 0);
    if(abs(k) >= A[n+1]) return 0;
    if(dp[n].count(k)) return dp[n][k];
    ll ret = 0;
    ll tmp = (k%A[n]+A[n])%A[n];
    if(abs(k-tmp)/A[n] < A[n+1]/A[n]) ret += solve(n-1, tmp);
    tmp -= A[n];
    if(abs(k-tmp)/A[n] < A[n+1]/A[n]) ret += solve(n-1, tmp);
    return dp[n][k] = ret;
}

signed main(){
    cin >> N >> X;
    rep(i, N) cin >> A[i];
    A[N] = 1e18L;

    cout << solve(N-1, -X) << endl;
}