
using namespace std;

#define visual

#ifdef visual
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>
#endif
#ifndef visual
#include <bits/stdc++.h>
#endif

typedef long long ll;

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<char> v;
    for (int i = 0; i < n; i++) {
        v.push_back(s[i]);
    }



    for (int i = 0; i < k; i++) {
        vector<char> u;
        if (v.size() % 2 == 0) {
            for (int j = 0; j < v.size(); j += 2) {
                u.push_back(win(v[j], v[j + 1]));
            }
        }
        else {
            for (int j = 0; j < 2*v.size(); j += 2) {
                u.push_back(win(v[j%v.size()], v[(j + 1)%v.size()]));
            }
        }



        v = u;
    }
    cout << v[0] << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll maxn=2e5+10;
const ll m1=1e18+7;
const ll mod=1e18+7;
const ll INF64 = ll(1e18);


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
ll t[4*maxn];
void build(ll a[], ll v, ll tl, ll tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        ll tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = t[v*2] + t[v*2+1];
    }
}
ll sum(ll v, ll tl, ll tr, ll l, ll r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    ll tm = (tl + tr) / 2;
    return sum(v*2, tl, tm, l, min(r, tm))
           + sum(v*2+1, tm+1, tr, max(l, tm+1), r);
}
void update(ll v, ll tl, ll tr, ll pos, ll new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        ll tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = t[v*2] + t[v*2+1];
    }
}
bool compare(pair<ll,ll> p1,pair<ll,ll> p2)
{
	if(p1.second==p2.second)
	{
		return(p1.first<p2.first);
	}
	else
		return(p1.second<p2.second);
}

int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
//long long tt = clock();
#endif
ios_base::sync_with_stdio(NULL);  cin.tie(0); cout.tie(0);
//Line Sweep

ll n,m,n2,i;
cin>>n>>m>>n2;
vector<pair<ll,ll>> v;

ll x_l=INT_MAX,y_l=INT_MAX;
for(i=0;i<n2;++i)
{
	ll x,y;
	cin>>x>>y;
	if(x==1)
	{
		x_l=min(x_l,y);
	}
	if(y==1)
	{
		y_l=min(y_l,x);
	}
	v.push_back(make_pair(x,y));

}
for(i=1;i<=m;++i)
{
	v.push_back(make_pair(0,i));
	v.push_back(make_pair(n+1,i));
}
if(x_l!=INT_MAX)
{
	for(i=x_l+1;i<=m;++i)
	{
		v.push_back(make_pair(1,i));
	}
}
if(y_l!=INT_MAX)
{
	for(i=y_l+1;i<=n;++i)
	{
		v.push_back(make_pair(i,1));
	}
}
sort(v.begin(),v.end(),compare);
ll active[maxn];

memset(active,0,sizeof(active));
build(active,1,0,maxn-1);
ll ans=0;
/*for(i=0;i<v.size();++i)
{
	cout<<v[i].first<<" "<<v[i].second<<"\n";
}*/

for(i=0;i<v.size()-1;++i)
{	active[v[i].first]=1;

	update(1,0,maxn-1,v[i].first,1);
	if(v[i].second!=v[i+1].second)
	{
		
		continue;
	}
	if(v[i].first==v[i+1].first)
		continue;
	
	ll diff=v[i+1].first-v[i].first-1;
	if(v[i].first==0)
	{
		ans+=diff;
	}
	else
	{
		ans+=diff-(v[i].first+1<=v[i+1].first-1?sum(1,0,maxn-1,v[i].first+1,v[i+1].first-1):0);
	}
	
}
cout<<ans;



return(0);
}