#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define REP(i,x,y) for(ll i = x;i <= y;++i)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
void solver() {
    string s;
    cin >> s;
    reverse(all(s));
    for(auto &c : s) {
        if(c == '6') {
            c = '9';
        } else if(c == '9') {
            c = '6';
        }
    }
    cout << s << "\n";
    return;
}
int main() {

    localTest();
    fastio;
    int t = 1;
    // cin >> t;
    while(t--) {
        solver();
    }

    return 0;
}
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

char fc(char x, char y){
  if(x == y) return x;
  if(x == 'R'){
    if(y == 'P') return y;
    else return x;
  }else if(x == 'P'){
    if(y == 'S') return y;
    else return x;
  }else{
    if(y == 'R') return y;
    else return x;
  }
}

char rc(int pos, int lv, string &s, int &nxpos){
  static vector<vector<char>> dp(lv+1, vector<char>(s.size(), 0));
  static vector<vector<int>> posdp(lv+1, vector<int>(s.size(), -1));
  int n = s.size();
  if(dp.at(lv).at(pos) != 0){
    nxpos = posdp.at(lv).at(pos);
    return dp.at(lv).at(pos);
  }
  if(lv == 0){
    nxpos = (pos+1) % n;
    return s.at(pos);
  }
  int rpos;
  char l = rc(pos, lv-1, s, rpos);
  char r = rc(rpos, lv-1, s, nxpos);
  posdp.at(lv).at(pos) = nxpos;
  return dp.at(lv).at(pos) = fc(l, r);
}

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int tmp;
  cout << rc(0, k, s, tmp) << endl;
  return 0;
}