#include<bits/stdc++.h>
#define int long long
using namespace std;
int b,c,ans;
signed main()
{
	scanf("%lld%lld",&b,&c);
	int que=c/2,ko=(c-1)/2,ko2=(c-2)/2;
//	b=abs(b);
	int l1=b-que,r1=b+ko2;
	int l2=-b-ko,r2=-b+ko;
	if(l1<=r2) printf("%lld\n",max(r1,r2)-min(l1,l2)+1);
	else printf("%lld\n",r1-l1+1+r2-l2+1);

	return 0;
}
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (decltype(end) i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (decltype(end) i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (decltype(beg) i = beg; end <= i; i--)
#define REP(n)              for (decltype(n) repeat_index = 0; repeat_index < n; repeat_index++)

using namespace std;

template<typename T, size_t S>
T minval(const T(&vals)[S])
{
	T val = numeric_limits<T>::max();
	FOR_LT(i, 0, S) {
		val = min(val, vals[i]);
	}
	return val;
}

template<typename T, size_t S>
T maxval(const T(&vals)[S])
{
	T val = numeric_limits<T>::min();
	FOR_LT(i, 0, S) {
		val = max(val, vals[i]);
	}
	return val;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, k; cin >> n >> k;
	string s; cin >> s;
	if (s.size() & 1) {
		s = s + s;
	}

	REP(k) {
		FOR_LT(i, 0, s.size() / 2) {
			if (s[i * 2] == s[i * 2 + 1]) {
				s[i] = s[i * 2];
				continue;
			}

			bool hand[3] = {};
			FOR_LT(j, 0, 2) {
				switch(s[i * 2 + j]) {
				case 'R': hand[0] = true; break;
				case 'P': hand[1] = true; break;
				case 'S': hand[2] = true; break;
				}
			}
			FOR_LT(j, 0, 3) {
				if (!hand[j]) {
					switch (j) {
					case 0: s[i] = 'S'; break;
					case 1: s[i] = 'R'; break;
					case 2: s[i] = 'P'; break;
					}
				}
			}
		}
		FOR_LT(i, 0, s.size() / 2) {
			s[s.size() / 2 + i] = s[i];
		}
	}

	cout << s[0] << endl;
	

	return 0;
}