// Template #include "bits/stdc++.h" #define rep_override(x, y, z, name, ...) name #define rep2(i, n) for (int i = 0; i < (int)(n); ++i) #define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i) #define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__) #define per(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; constexpr int inf = 1001001001; constexpr ll INF = 3003003003003003003LL; template inline bool chmin(T &x, const T &y) { if (x > y) { x = y; return true; } return false; } template inline bool chmax(T &x, const T &y) { if (x < y) { x = y; return true; } return false; } struct IOSET { IOSET() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } ioset; // Main using ld = long double; ld p, q, r; ld change(ld x) { return x * (1 - r) + (1 - x) * r; } ld OR(ld x, ld y) { return change(1 - (1 - x) * (1 - y)); } ld AND(ld x, ld y) { return change(x * y); } ld random(ld x, ld y) { return x * y * p + (1 - x * y) * q; } using State = string::const_iterator; ld expr(State &state); ld term(State &state); ld rfactor(State &state); ld factor(State &state); ld val(State &state); ld expr(State &state) { ld x = term(state), res = 0; if (*state == 'o') { state += 2; ld y = expr(state); res = OR(x, y); } else { res = x; } return res; } ld term(State &state) { ld x = rfactor(state), res = 0; if (*state == 'a') { state += 3; ld y = term(state); res = AND(x, y); } else { res = x; } return res; } ld rfactor(State &state) { ld res = 0; if (*state == 'r') { state += 7; ld x = expr(state); ld y = expr(state); res = random(x, y); } else { res = factor(state); } return res; } ld factor(State &state) { ld res = 0; if (*state == '(') { ++state; res = expr(state); ++state; } else { res = val(state); } return res; } ld val(State &state) { if (*state == 'Y') { state += 3; return 1; } else { state += 2; return 0; } } int main() { int n; string s; cin >> n >> p >> q >> r >> s; State state = s.begin(); cout << (int)(expr(state) * 100) << "\n"; }