#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)


void solve(long long X, long long Y, long long A, long long B) {

    ll exp_a = 0;
    while (true) {
        if (X > Y / A) break;
        if (X * A >= X + B) break;
        if (X * A >= Y) break;

        X *= A;
        exp_a++;
    }
    ll exp_b = (Y - X - 1) / B;
    cout << exp_a + exp_b << endl;
}

int main() {
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(X, Y, A, B);
    return 0;
}

#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int>
#define all(v) v.begin(), v.end()
#define mt make_tuple
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
#define prev prev1
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R)
{
     int val = rng() % R;
     assert(val >= 0);
     return val;
}

const long double PI = atan(1.0) * 4;
const int32_t INF32 = 2e9 + 7;
const int64_t INF64 = 3e18;
const int32_t LOG = 21;
const int32_t MOD = MOD1;

using namespace std;

//-------------------DEBUGGING-------------------------
void my_debugger(string s, int LINE_NUM) { cerr << endl; }
template <typename start, typename... end>
void my_debugger(string s, int LINE_NUM, start x, end... y)
{
     if (s.back() != ',')
     {
          s += ',';
          cerr << "LINE(" << LINE_NUM << "): ";
     }
     int i = s.find(',');
     cerr << s.substr(0, i) << " = " << x;
     s = s.substr(i + 1);
     if (!s.empty())
          cerr << ", ";
     my_debugger(s, LINE_NUM, y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__, __LINE__, __VA_ARGS__);
#else
#define debug(...) ;
#endif

//-----------------------------------------------------


int32_t main()
{
     getFaster;
     //files_init();
     int tests = 1;
     //cin >> tests;
     rep(ii, 0, tests)
     {
          int n,k;
          cin>>n>>k;
          string s;
          cin>>s;
          vector<int> pow2(k+1,1);
          rep(i,1,k+1)pow2[i]=(pow2[i-1]*2)%n;
          vector<vector<int>> dp(n+1,vector<int>(k+1,0));
          map<char,int> m;
          m['R']=0,m['P']=1,m['S']=2;
          vector<char> convert={'R','P','S'};
          rep(round,0,k+1)
          {
               rep(i,0,n)
               {
                      if(round==0)
                      {
                           dp[i][round]=m[s[i]];
                           continue;
                      }             
                      int val1=dp[i][round-1];
                      int val2=dp[(i+pow2[round-1])%n][round-1];
                      if(val1>val2)swap(val1,val2);
                      if(val1==val2 || val1+1==val2)
                      dp[i][round]=val2;
               }
          }
          cout<<convert[dp[0][k]]<<endl;
     }
     return 0;
}