#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &x, T2 y) {
  x = (x > y ? y : x);
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, T2 y) {
  x = (x < y ? y : x);
}
using ll = long long;
const string FILENAME = "input";
const int Mod = 998244353;
int n;
string s;
vector<int> pos[3];
int cnt[8];
int get(char c) {
  if (c == 'R') {
    return 0;
  }
  if (c == 'G') {
    return 1;
  }
  return 2;
}
int mul(int a, int b) { return (1LL * a * b) % Mod; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  n *= 3;
  cin >> s;
  cnt[0] = n / 3;
  int ans = 1;
  for (int i = 0; i < n; i++) {
    int c = get(s[i]);
    int cand = -1;
    for (int j = 0; j < 7; j++) {
      if (cnt[j]) {
        if (((1 << c) ^ j) > j) {
          cand = j;
        }
      }
    }
    ans = mul(ans, cnt[cand]);
    cnt[cand]--;
    cnt[cand ^ (1 << c)]++;
  }
  cout << ans << '\n';
  return 0;
}
