#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

ll dp[1 << 20];

vector<int> pr = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};

int getmask(ll v) {
  int mask = 0;
  for (int i = 0; i < 20; i++) {
    if (v % pr[i] == 0) mask |= (1 << i);
  }
  return mask;
}

void solve() {
  ll a, b; cin >> a >> b;
  dp[0] = 1;
  for (ll v = a; v <= b; v++) {
    int mymask = getmask(v);
    for (int mask = 0; mask < (1 << 20); mask++) {
      if (mask & mymask) continue;
      dp[mask | mymask] += dp[mask];
    }
  }
  cout << accumulate(dp, dp + (1 << 20), 0ll);
}

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n,k;
    std::cin >> n>>k;
    
    string s;
    std::cin >> s;
    
    string next = s+s;
    
    for (int jjjj = 0; jjjj < k; jjjj++) {
        s = next;
        for (int i = 0; i < 2*n; i++) {
            char x;
            if(s[2*i%(2*n)]=='R'){
                if(s[(2*i+1)%(2*n)]=='P'){
                    x= 'P';
                }else{
                    x= 'R';
                }
            }else if(s[2*i%(2*n)]=='P'){
                if(s[(2*i+1)%(2*n)]=='S'){
                    x= 'S';
                }else{
                    x= 'P';
                }
            }else{
                if(s[(2*i+1)%(2*n)]=='R'){
                    x= 'R';
                }else{
                    x= 'S';
                }
            }
            next[i] =x;
        }
    }
    
    std::cout << next[0] << std::endl;
}
