#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    string S;
    cin >> N >> S;

    map<char, vector<set<char>>> targets;
    targets['R'].push_back({'G', 'B'});
    targets['R'].push_back({'G'});
    targets['R'].push_back({'B'});
    targets['R'].push_back({});
    targets['G'].push_back({'R', 'B'});
    targets['G'].push_back({'R'});
    targets['G'].push_back({'B'});
    targets['G'].push_back({});
    targets['B'].push_back({'R', 'G'});
    targets['B'].push_back({'R'});
    targets['B'].push_back({'G'});
    targets['B'].push_back({});

    constexpr ll MOD = 998244353;

    ll ans = 1;
    for (ll i = 1; i <= N; i++) {
        (ans *= i) %= MOD;
    }
    map<set<char>, ll> mp;
    mp[{}] = 1;
    for (const char& c : S) {
        for (set<char> target : targets[c]) {
            if (mp[target] > 0) {
                (ans *= mp[target]) %= MOD;
                mp[target]--;
                target.insert(c);
                mp[target]++;
                break;
            }
        }
        mp[{}] = 1;
    }
    cout << ans << endl;
}