#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
typedef long long ll;
// 1 = R 2 = B 3 = G 4 = RG 5 = RB 6 = GB

int main()
{
	ll n,ans = 1;
	ll a[7] = {0};
	string s;
	cin >> n >> s;
	a[0] = n;
	
	for(int i = 0;i < s.size();i++){
		if(s[i] == 'R'){
			if(a[5]) {ans = ans*a[5]%MOD;a[5]--;}
			else if(a[2]) {ans = ans*a[2]%MOD;a[2]--;a[4]++;}
			else if(a[3]) {ans = ans*a[3]%MOD;a[3]--;a[6]++;}
			else {ans = ans*a[0]%MOD;a[0]--;a[1]++;}
		}
		else if(s[i] == 'B'){
			if(a[6]) {ans = ans*a[6]%MOD;a[6]--;}
			else if(a[1]) {ans = ans*a[1]%MOD;a[1]--;a[4]++;}
			else if(a[3]) {ans = ans*a[3]%MOD;a[3]--;a[5]++;}
			else {ans = ans*a[0]%MOD;a[0]--;a[2]++;}
		}
		else{
			if(a[4]) {ans = ans*a[4]%MOD;a[4]--;}
			else if(a[1]) {ans = ans*a[1]%MOD;a[1]--;a[6]++;}
			else if(a[2]) {ans = ans*a[2]%MOD;a[2]--;a[5]++;}
			else {ans = ans*a[0]%MOD;a[0]--;a[3]++;}
		}
	}
	
	cout << ans << endl;
	return 0;
}