#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

char janken(char c1, char c2) {
  if (c1 == 'R') {
    if (c2 == 'P') return 'P';
    if (c2 == 'S') return 'R';
  }
  if (c1 == 'P') {
    if (c2 == 'R') return 'P';
    if (c2 == 'S') return 'S';
  }
  if (c1 == 'S') {
    if (c2 == 'R') return 'R';
    if (c2 == 'P') return 'S';
  }
  return c1;
}

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

  for (int j = 0; j < k; j++) {
    tmp = s + s;
    for (int i = 0; i < n; i++) {
      s[i] = janken(tmp[i * 2], tmp[i * 2 + 1]);
    }
  }

  cout << s[0] << '\n';
  return 0;
}
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

struct Data
{
  int cnt, value;
  Data operator+(const Data &other)
  {
    if (cnt == 0 && other.cnt == 0)
      return value < other.value ? *this: other;
    if (cnt == 0)
      return *this;
    if (other.cnt == 0)
      return other;
    return *this;
  }
};
const Data nil = Data{1, (int)1e9};

// DON'T FORGET TO DEFINE THE NIL!!!
template<class T>
struct Segtree
{
  int size;
  T nil;
  vector<T> data;
  vector<T> st;
  Segtree() { }
  Segtree(int size, T nil) : size(size), nil(nil)
  {
    data.resize(size, nil);
    st.resize(4*size, nil);
  }
  Segtree(vector<T> &data, T nil) : size(data.size()), data(data), nil(nil)
  {
    st.resize(4*size);
    build();
  }
  void build() { build(1, 0, size - 1); }
  T query(int qlo, int qhi) { return query(qlo, qhi, 1, 0, size - 1); }
  void update(int pos, T value) { update(pos, value, 1, 0, size - 1); }
  void build(int i, int lo, int hi)
  {
    if (lo == hi)
    {
      st[i] = data[lo];
      return;
    }
    int mid = (lo + hi) >> 1;
    build(2*i, lo, mid), build(2*i + 1, mid + 1, hi);
    st[i] = st[2*i] + st[2*i + 1];
  }
  T query(int qlo, int qhi, int i, int lo, int hi)
  {
    if (hi < qlo || lo > qhi) return nil;
    if (lo >= qlo && hi <= qhi) return st[i];
    int mid = (lo + hi) >> 1;
    return query(qlo, qhi, 2*i, lo, mid) + query(qlo, qhi, 2*i + 1, mid + 1, hi);
  }
  void update(int pos, T &value, int i, int lo, int hi)
  {
    if (lo == hi)
    {
      // st[i] = data[lo] = value;
      st[i].cnt += value.cnt;
      return;
    }
    int mid = (lo + hi) >> 1;
    if (pos <= mid) update(pos, value, 2*i, lo, mid);
    else update(pos, value, 2*i + 1, mid + 1, hi);
    st[i] = st[2*i] + st[2*i + 1];
  }
};
Segtree<Data> segtree;

const int maxN = 1500000; int n, m;
int a[maxN];

int main()
{
  while (~scanf("%d %d", &n, &m))
  {
    segtree = Segtree<Data>(maxN + 1, nil);
    for (int i = 0; i < n; i++)
      scanf("%d", &a[i]);

    int ans = 1e9;
    for (int i = 0; i <= maxN; i++)
      segtree.data[i] = Data{0, i};
    segtree.build();
    for (int i = 0; i < m; i++)
      segtree.update(a[i], Data{1, 0});

    for (int i = 0; i + m - 1 < n; i++)
    {
      // [i : i + m - 1]
      ans = min(ans, segtree.query(0, maxN).value);
      segtree.update(a[i], Data{-1, 0});
      if (i + m < n) segtree.update(a[i + m], Data{1, 0});
    }
    printf("%d\n", ans);
  }
  return 0;
}