#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define repn(i,n) for(int i=1;i<=n;++i)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m,a[20][20],ok[300000],dp[300000];

int main()
{
  cin>>n>>m;
  int x,y;
  rep(i,m)
  {
    scanf("%d%d",&x,&y);
    --x;
    --y;
    a[x][y]=a[y][x]=1;
  }
  rep(i,1<<n)
  {
    bool b=true;
    rep(j,n) 
    {
      for(int k=j+1;k<n;k++)
      {
        if((i&(1<<j))==0||(i&(1<<k))==0) continue;
        if(a[j][k]==0)
        {
          b=false;
          break;
        }
      }
      if(!b) break;
    }
    ok[i]=(int)b;
  }
  rep(i,(1<<n)+5) dp[i]=1e9;
  dp[0]=0;
  rep(i,1<<n)
  {
    if(dp[i]==1e9) continue;
    int lft=(1<<n)-1-i;
    for(int sub=lft;sub>0;sub=(sub-1)&lft) if(ok[sub]==1) dp[i|sub]=min(dp[i|sub],dp[i]+1);
  }
  cout<<dp[(1<<n)-1]<<endl;
	return 0;
}
#include "bits/stdc++.h"
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;


char win(char a,char b){
    if(a==b)return a;
    if(a=='R'){
        if(b=='P')return b;
        else return a;
    }
    if(a=='P'){
        if(b=='S')return b;
        else return a;
    }
    if(a=='S'){
        if(b=='R')return b;
        else return a;
    }
    return a;
}

void solve(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    for (int i = 0; i < k; ++i) {
        if(sz(s)%2){
            s+=s;
        }
        string t = "";
        for (int j = 0; j < sz(s); j+=2) {
            t+=win(s[j],s[j+1]);
        }
        s=t;
    }   
    cout<<s[0]; 

}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
        sieve();
    #endif
    #ifdef NCR
        init();
    #endif
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
