#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int64_t>;
using vvi = vector<vi>;
using vc  = vector<char>;
using vvc = vector<vc>;
using vd  = vector<long double>;
using vvd = vector<vd>;
using pii = pair<int64_t, int64_t>;
using vvp = vector<vector<pii>>;
int64_t INF = 1e18;
int64_t mod = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  string ns;
  rep(j, k) {
    ns = "";
    int a;
    if (n % 2 == 0) a = n /2;
    else a = n;
    for(int i = 0; i < n * 2; i += 2) {
      if (s[i % n] == s[(i+1) % n]) ns += s[i % n];
      else if ((s[i % n] == 'R' && s[(i+1) % n] == 'S') || (s[i % n] == 'P' && s[(i+1) % n] == 'R') || (s[i % n] == 'S' && s[(i+1) % n] == 'P')) ns += s[i % n];
      else ns += s[(i+1) % n];
    }
    s = ns;
    n = s.size();
  }
  cout << ns[0] << endl;
}

# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
#define MOD 1000000007
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int A1, A2, A3, A4;

int main(){
        cin >> A1 >> A2 >> A3 >> A4;

        cout << min(min(A1, A2), min(A3, A4)) << endl;
        return 0;
}