#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans = 0;
char battle(char a, char b){
    if(a == b) return a;
    else{
        string s = "";
        s.push_back(a);
        s.push_back(b);
        sort(s.begin(), s.end());//PRS
        if(s == "PR") return 'P';
        else if(s == "PS") return 'S';
        else return 'R';
    }
}
string winner(string s){
    string ret = "";
    for(int i=0; i<s.size(); i += 2){
        ret.push_back(battle(s[i], s[i+1]));
    }
    return ret;
}
void Main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    string s2 = s;
    For(i,0,k){
        if(s.size() % 2 == 1)s = s + s;
        s = winner(s);
    }
    auto ans1 = s[0];
    cout << s[0] << endl;
    /*
    s = s2 + s2;
    int pw = 1;
    For(i,0,k) pw *= 2;
    while(s.size() < pw) s = s + s;
    while(s.size() > pw) s.pop_back();
    //cout << s << endl;
    while(s.size() > 1){
        s = winner(s);
        //cout << s << endl;
    }
    //string nexts = winner(s);
    //cout << nexts << endl;
    auto ans2 = s[0];
    cout << ans1 << " " << ans2 << endl;
    */
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define MP make_pair
#define PB push_back
#define REP(i, L, R) for (int i = L; i < (R); ++i)
#define SZ(x) (int)x.size()

using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

template <typename T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template <typename T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

vector<int> compress(vector<int> &y)
{
    vector<int> v(y);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for (int i = 0; i < SZ(y); ++i)
    {
        y[i] = lower_bound(v.begin(), v.end(), y[i]) - v.begin();
    }

    return v;
}

struct bit
{
    int n;
    vector<ll> v;

    void init(int sz)
    {
        n = sz;
        v.assign(n + 1, 0);
    }

    // sum([0..i])
    ll prefix_sum(int i)
    {
        // internally we use 1-based index
        int _i = i + 1;
        ll s = 0LL;
        while (_i)
        {
            s += v[_i];
            _i -= (_i & -_i);
        }
        return s;
    }

    // sum([i..end])
    ll suffix_sum(int i)
    {
        if (i == 0)
        {
            return prefix_sum(n - 1);
        }

        return prefix_sum(n - 1) - prefix_sum(i - 1);
    }

    void incr(int i, ll a)
    {
        // internally we use 1-based indexing
        int _i = i + 1;
        while (_i <= n)
        {
            v[_i] += a;
            _i += (_i & -_i);
        }
    }
};

const int MAXN = 200005;
void solve()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> t(q + 1), x(q + 1), y(q + 1, 0);
    vector<int> a(n, 0), b(m, 0);
    REP(i, 1, q + 1)
    {
        cin >> t[i] >> x[i] >> y[i];
        --x[i]; // 0-based index
    }

    auto vy = compress(y);
    // NOTE 1(coordinate compression): after compression, y is compressed to [0, q] and vy maps from a compressed y in [0,q] to its original value.

    // r1[i] = #i in b; r2[i] = sum of all i's in b.
    // c1[i] = #i in a; c2[i] = sum of all i's in a.
    bit r1, r2, c1, c2;
    r1.init(MAXN);
    r2.init(MAXN);
    c1.init(MAXN);
    c2.init(MAXN);
    // Initially, all b are 0
    r1.incr(0, m);
    // Initially, all a are 0
    c1.incr(0, n);

    ll ans = 0LL;
    REP(i, 1, q + 1)
    {
        if (t[i] == 1)
        {
            // a[x[i]] = y[i]
            int v = a[x[i]];
            ans -= vy[v] * r1.prefix_sum(v);
            ans -= r2.suffix_sum(v + 1);
            c1.incr(v, -1);
            c2.incr(v, -vy[v]);

            a[x[i]] = y[i];
            c1.incr(y[i], 1);
            c2.incr(y[i], vy[y[i]]);
            ans += vy[y[i]] * r1.prefix_sum(y[i]);
            ans += r2.suffix_sum(y[i] + 1);
        }
        else
        {
            // b[x[i]] = y[i]
            int v = b[x[i]];
            ans -= vy[v] * c1.prefix_sum(v);
            ans -= c2.suffix_sum(v + 1);
            r1.incr(v, -1);
            r2.incr(v, -vy[v]);

            b[x[i]] = y[i];
            r1.incr(y[i], 1);
            r2.incr(y[i], vy[y[i]]);
            ans += vy[y[i]] * c1.prefix_sum(y[i]);
            ans += c2.suffix_sum(y[i] + 1);
        }
        cout << ans << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}
