#include using namespace std; constexpr int mod = 998244353; long long fac[200005], finv[200005], inv[200005]; void COMinit() { fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1; for (int i = 2; i < 200005; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long COM(int n, int k){ if(n == k) return 1; if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } int main() { string S; int A,B,C; cin >> S >> A >> B >> C; int P = 0,Q = 0,R = 0; for(int i = 0; i < S.size(); i++) { if(S[i] == 'a') P++; if(S[i] == 'b') Q++; if(S[i] == 'c') R++; } COMinit(); int T=A-P,U=B-Q,V=C-R; int ans = 0; for(int k = 0; k <= T+U; k++) { int cnt1 = 0; for(int i = 0; i <= k; i++) { cnt1 += COM(R-1+i,R-1)*COM(V+P+Q+T+U-i+1-1,V)%mod; cnt1 %= mod; } int cnt2 = 0; for(int i = max(0,k-U); i <= T && i <= k; i++) { cnt2 += COM(k,i)*COM(T-i+Q-1,Q-1)%mod*COM(U-(k-i)+P-1,P-1)%mod; cnt2 %= mod; } ans += (long(cnt1) * cnt2) % mod; ans %= mod; } cout << ans << endl; }