#ifndef KOMAKI_LOCAL
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <sys/time.h>
#include <unistd.h>
using namespace std;
#define i64         int64_t
#define rep(i, n)   for(i64 i = 0; (i) < ((i64)(n)); ++(i))
#define bit(n)      (((i64)1)<<((i64)(n)))
#define sz(v)       ((i64)((v).size()))

std::string dbgDelim(int &i){ return (i++ == 0 ? "" : ", "); }
#define dbgEmbrace(exp) { int i = 0; os << "{"; { exp; } os << "}"; return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> v);
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> v);
template <class T> std::ostream& operator<<(std::ostream &os, std::queue<T> q);
template <class T> std::ostream& operator<<(std::ostream &os, std::priority_queue<T> q);
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::pair<T, K> p);
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> mp);
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::unordered_map<T, K> mp);
template <int INDEX, class TUPLE> void dbgDeploy(std::ostream &os, TUPLE _){}
template <int INDEX, class TUPLE, class H, class ...Ts> void dbgDeploy(std::ostream &os, TUPLE t){ os << (INDEX == 0 ? "" : ", ") << get<INDEX>(t); dbgDeploy<INDEX + 1, TUPLE, Ts...>(os, t); }
template <class T, class K> void dbgDeploy(std::ostream &os, std::pair<T, K> p, std::string delim){ os << "(" << p.first << delim << p.second << ")"; }
template <class ...Ts> std::ostream& operator<<(std::ostream &os, std::tuple<Ts...> t){ os << "("; dbgDeploy<0, std::tuple<Ts...>, Ts...>(os, t); os << ")"; return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::pair<T, K> p){ dbgDeploy(os, p, ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> v){ dbgEmbrace( for(T t: v){ os << dbgDelim(i) << t; }); }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> s){ dbgEmbrace( for(T t: s){ os << dbgDelim(i) << t; }); }
template <class T> std::ostream& operator<<(std::ostream &os, std::queue<T> q){ dbgEmbrace( for(; q.size(); q.pop()){ os << dbgDelim(i) << q.front(); }); }
template <class T> std::ostream& operator<<(std::ostream &os, std::priority_queue<T> q){ dbgEmbrace( for(; q.size(); q.pop()){ os << dbgDelim(i) << (T) q.top();   }); }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> mp){ dbgEmbrace( for(auto p: mp){ os << dbgDelim(i); dbgDeploy(os, p, "->"); }); }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::unordered_map<T, K> mp){ dbgEmbrace( for(auto p: mp){ os << dbgDelim(i); dbgDeploy(os, p, "->"); }); }
#define DBG_OUT std::cerr
#define DBG_OVERLOAD(_1, _2, _3, _4, _5, _6, macro_name, ...) macro_name
#define DBG_LINE() { char s[99]; sprintf(s, "line:%3d | ", __LINE__); DBG_OUT << s; }
#define DBG_OUTPUT(v) { DBG_OUT << (#v) << "=" << (v); }
#define DBG1(v, ...) { DBG_OUTPUT(v); }
#define DBG2(v, ...) { DBG_OUTPUT(v); DBG_OUT << ", "; DBG1(__VA_ARGS__); }
#define DBG3(v, ...) { DBG_OUTPUT(v); DBG_OUT << ", "; DBG2(__VA_ARGS__); }
#define DBG4(v, ...) { DBG_OUTPUT(v); DBG_OUT << ", "; DBG3(__VA_ARGS__); }
#define DBG5(v, ...) { DBG_OUTPUT(v); DBG_OUT << ", "; DBG4(__VA_ARGS__); }
#define DBG6(v, ...) { DBG_OUTPUT(v); DBG_OUT << ", "; DBG5(__VA_ARGS__); }

#define DEBUG0() { DBG_LINE(); DBG_OUT << std::endl; }
#define DEBUG(...)                                                      \
  {                                                                     \
    DBG_LINE();                                                         \
    DBG_OVERLOAD(__VA_ARGS__, DBG6, DBG5, DBG4, DBG3, DBG2, DBG1)(__VA_ARGS__); \
    DBG_OUT << std::endl;                                               \
  }

/******************************************************************/
/*                                                                */
/* Undefine "GF_USE_FIXED_GF" to use various mods, but slower.    */
/* To use fixed one, set your mod at "static const int mod = ;"   */
/*                                                                */
/******************************************************************/

#define GF_USE_FIXED_GF
template <typename T> class GF
{
public:
#ifdef GF_USE_FIXED_GF
    static const T mod = 998244353; // Set your mod!
    GF() { permutation_memo = std::vector<T>(1, 1); inverse_memo = std::vector<T>(2, 1); permutation_inverse_memo = std::vector<T>(2, 1); }
#else
    T mod;
  GF(T mod) : mod(mod) { permutation_memo = std::vector<T>(1, 1); inverse_memo = std::vector<T>(2, 1); permutation_inverse_memo = std::vector<T>(2, 1); }
#endif


    T norm(T i);

    T add(T i0, T i1);
    T sub(T i0, T i1);
    T mul(T i0, T i1);
    T div(T i0, T i1);
    T pow(T i, int64_t p);
    T inv(T i);
    T permInv(T i);

    T permutation(T n, T m); // n * (n - 1) * ... * (n - m + 1), Non limited memorization, Avoid segmentation fault!
    T combination(T n, T m); // Memorized for n < MEMO_SIZE_LIMIT.

private:
    static const int MEMO_SIZE_LIMIT = 2000000;
    std::vector<T> permutation_memo;
    std::vector<T> inverse_memo;
    std::vector<T> permutation_inverse_memo;
};


template <typename T>
inline T GF<T>::permutation(T n, T m)
{
  if(m < 0 || n < m) return 0;
  while(permutation_memo.size() <= n){
    permutation_memo.push_back(mul(permutation_memo.back(), permutation_memo.size()));
  }
  return mul(permutation_memo[n], permInv(n - m));
}

template <typename T>
inline T GF<T>::combination(T n, T m)
{
  if(m < 0 || n < m) return 0;
  if(n - m < m) m = n - m;

  if(n < MEMO_SIZE_LIMIT){
    T num = permutation(n, n);
    T den = mul(permInv(m), permInv(n - m));
    return mul(num, den);
  }

  T num = 1, den = 1;
  for(T i = 0; i < m; ++i){
    num = mul(num, n - i);
    den = mul(den, i + 1);
  }
  return div(num, den);
}

template <typename T>
inline T GF<T>::norm(T i)
{
  return (i % mod + mod) % mod;
}

template <typename T>
inline T GF<T>::add(T i0, T i1)
{
  T res = i0 + i1;
  if(mod <= res) return res - mod;
  return res;
}

template <typename T>
inline T GF<T>::sub(T i0, T i1)
{
  T res = i0 - i1;
  if(res < 0) return res + mod;
  return res;
}

template <typename T>
inline T GF<T>::mul(T i0, T i1)
{
  return (int64_t)i0 * i1 % mod;
}

template <typename T>
inline T GF<T>::div(T i0, T i1)
{
  return mul(i0, inv(i1));
}

template <typename T>
inline T GF<T>::permInv(T i)
{
  while(permutation_inverse_memo.size() <= i){
    permutation_inverse_memo.push_back(mul(permutation_inverse_memo.back(), inv(permutation_inverse_memo.size())));
  }
  return permutation_inverse_memo[i];
}

template <typename T>
inline T GF<T>::inv(T i)
{
  if(i < MEMO_SIZE_LIMIT){
    while(inverse_memo.size() <= i){
      // Deformation of formula.
      // b[t] * t = (M - (M / t) * t) * b[M - (M / t) * t];
      // Divides by i over a finite field GF(mod), b[t] = - (M / t) * b[M % t].
      int size = inverse_memo.size();
      inverse_memo.push_back(mod - (int64_t)(mod / size) * inverse_memo[mod % size] % mod);
    }
    return inverse_memo[i];
  }

  return this->pow(i, mod - 2);
}

template <typename T>
inline T GF<T>::pow(T i, int64_t p)
{
  T res = 1;
  for(; p; p >>= 1){
    if(p & 1) res = mul(res, i);
    i = mul(i, i);
  }
  return res;
}




vector<i64> getDegrees(string s)
{
  unordered_map<char, i64> mp;
  mp['R'] = 0;
  mp['G'] = 1;
  mp['B'] = 2;
  vector<i64> positions[3];
  rep(i, sz(s)) positions[mp[s[i]]].push_back(i);

  vector<i64> degrees(sz(s));
  rep(i, sz(positions[0])){
    vector<i64> v;
    rep(j, 3) v.push_back(positions[j][i]);
    sort(v.begin(), v.end());
    rep(j, 3) degrees[v[j]] = j;
  }
  return degrees;
}

GF<i64> gf;
int main()
{
  string s;
  cin >> s >> s;
  vector<i64> degrees = getDegrees(s);

  i64 res = 1;
  vector<i64> counts({sz(degrees) / 3, 0, 0, 0});
  rep(i, sz(degrees)){
    // DEBUG(counts, degrees[i], res);
    res = gf.mul(res, counts[degrees[i]]);
    --counts[degrees[i]];
    ++counts[degrees[i] + 1];
  }
  cout << res << endl;
}

Measured memory_bytes: 6004