#include #include using namespace std; int main(void) { int n, q, k; string s; cin >> n >> s; vector enemy(n); for (int i = 0; i < n; ++i) cin >> enemy[i]; cin >> q; for (int i = 0; i < q; ++i) { cin >> k; int max_ans = -1; for (int j = 0; j < n; ++j) { int beam = k; int cnt = j, ans = 0; while (beam > 0 && n > cnt) { beam -= enemy[cnt]; if (beam >= 0 && s[cnt] == 'E') ++ans; ++cnt; } max_ans = max(max_ans, ans); } cout << max_ans << endl; } return 0; }