Loose stones

Stones 1 to N lie in a line between the near bank (position 0) and the far bank (position N + 1). In the string S, 0 marks a solid stone and 1 a loose one. You can jump 1 place forward for X coins or 2 places for Y coins, but never past N + 1. If you land on a loose stone you slip back one place and stay there. Find the minimum cost to reach N + 1, or print -1 if it is impossible.

Reported in: Infosys (SP / DSE · 29 Nov 2026) (memory-based)

Input

First line: N. Second line: S. Third line: X and Y.

Output

The minimum cost, or -1.

Constraints

1 ≤ N ≤ 10^5; 1 ≤ X, Y ≤ 10^4.

Example 1

Input:
3
010
1 3

Output:
5

Example 2

Input:
4
0110
2 3

Output:
10

Example 3

Input:
2
11
1 1

Output:
2

Hint: A move never takes you backwards past where you started, so find the cheapest cost for positions 0, 1, 2, … in order: from p try both jumps, apply the slip, and update the place you end up.

All coding practice