You've got a string $a_1, a_2, \dots, a_n$, consisting of zeros and ones.

Let's call a sequence of consecutive elements $a_i, a_{i + 1}, \ldots, a_j$ ($1\leq i\leq j\leq n$) a substring of string $a$. 

You can apply the following operations any number of times:  Choose some substring of string $a$ (for example, you can choose entire string) and reverse it, paying $x$ coins for it (for example, «0101101» $\to$ «0111001»);  Choose some substring of string $a$ (for example, you can choose entire string or just one symbol) and replace each symbol to the opposite one (zeros are replaced by ones, and ones — by zeros), paying $y$ coins for it (for example, «0101101» $\to$ «0110001»). 

You can apply these operations in any order. It is allowed to apply the operations multiple times to the same substring.

What is the minimum number of coins you need to spend to get a string consisting only of ones?


-----Input-----

The first line of input contains integers $n$, $x$ and $y$ ($1 \leq n \leq 300\,000, 0 \leq x, y \leq 10^9$) — length of the string, cost of the first operation (substring reverse) and cost of the second operation (inverting all elements of substring).

The second line contains the string $a$ of length $n$, consisting of zeros and ones.


-----Output-----

Print a single integer — the minimum total cost of operations you need to spend to get a string consisting only of ones. Print $0$, if you do not need to perform any operations.


-----Examples-----
Input
5 1 10
01000

Output
11

Input
5 10 1
01000

Output
2

Input
7 2 3
1111111

Output
0



-----Note-----

In the first sample, at first you need to reverse substring $[1 \dots 2]$, and then you need to invert substring $[2 \dots 5]$. 

Then the string was changed as follows:

«01000» $\to$ «10000» $\to$ «11111».

The total cost of operations is $1 + 10 = 11$.

In the second sample, at first you need to invert substring $[1 \dots 1]$, and then you need to invert substring $[3 \dots 5]$. 

Then the string was changed as follows:

«01000» $\to$ «11000» $\to$ «11111».

The overall cost is $1 + 1 = 2$.

In the third example, string already consists only of ones, so the answer is $0$.

Difficulty: MEDIUM
Tags: Mathematics

Complete search

Implementation

Greedy algorithms
Skill types: Complete search

Greedy algorithms

Starter code:

Solutions:
from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial

def binNumber(n, size=1):
	return bin(n)[2:].zfill(size)

def iar():
	return list(map(int, input().split()))

def ini():
	return int(input())

def isp():
	return map(int, input().split())

def sti():
	return str(input())
(n, x, y) = isp()
s = sti()
p = 0
vl = False
for i in range(0, n - 1):
	if s[i] == '0':
		if vl == False:
			p += 1
			vl = True
		if s[i] != s[i + 1]:
			vl = False
if s[n - 1] == '0':
	if vl == False:
		p += 1
if p == 0:
	print(0)
else:
	print((p - 1) * min(x, y) + y)


(n, x, y) = map(int, input().split())
s = input().replace('1', ' ')
z = len(s.split())
print(z and (z - 1) * min(x, y) + y)


(n, x, y) = list(map(int, input().split()))
s = input().strip()

def solve(s, x, y):
	n0 = 0
	for i in range(len(s)):
		if s[i] == '0' and (i == 0 or s[i - 1] == '1'):
			n0 += 1
	if n0 == 0:
		return 0
	return (n0 - 1) * x + y if x < y else n0 * y
print(solve(s, x, y))


from functools import cmp_to_key
s = input()
s = s.split(' ')
n = int(s[0])
x = int(s[1])
y = int(s[2])
s = input()
s = list(s)
s.append('2')
p = 0
for i in range(1, len(s)):
	if s[i] != '0' and s[i - 1] == '0':
		p += 1
if p == 0:
	print(0)
else:
	print((p - 1) * min(x, y) + y)


(n, x, y) = list(map(int, input().split()))
a = input()
(n0, n1) = (len(list(filter(lambda x: x != '', a.split('1')))), len(list(filter(lambda x: x != '', a.split('0')))))
print(min(max(n0 * x - x + y, 0), max(n0 * y, 0)))


import math

def answer(n, x, y, A):
	count = 0
	sign = 1
	for i in range(n):
		if A[i] == '0' and sign:
			count += 1
			sign = 0
		elif A[i] == '1':
			sign = 1
	ans = 0
	if count == 0:
		return 0
	if y > x:
		return y + (count - 1) * x
	else:
		return count * y
(n, x, y) = map(int, input().split())
s = input()
print(answer(n, x, y, s))


(n, x, y) = map(int, input().split())
s = input()
(i, intervals) = (0, 0)
while i < n:
	j = i
	if s[i] == '0':
		curr_len = 0
		while j < n and s[j] == '0':
			j += 1
			curr_len += 1
		intervals += 1
	i = j + 1
if intervals == 0:
	print(intervals)
else:
	print(min(intervals * y, (intervals - 1) * x + y))


(n, x, y) = map(int, input().split())
s = input()
ne = 0
count = 0
for i in range(1, n + 1):
	if s[i - 1] == '0':
		count += 1
	if s[i - 1] == '1' or (s[i - 1] == '0' and i > 1 and (s[i - 2] == '0')):
		p = ne
	elif count == 1:
		ne += y
	else:
		ne += min(x, y)
print(ne)


(n, a, b) = map(int, input().split())
l = list(map(int, input()))
f = True
ans = 0
for t in l:
	if t == 0 and f:
		ans += 1
		f = False
	if t == 1:
		f = True
if ans == 0:
	print(0)
elif b <= a:
	print(ans * b)
else:
	print((ans - 1) * a + b)


(n, x, y) = map(int, input().split())
A = input()
cnt = 0
k = A.find('0')
while k < n and k != -1:
	while A[k] != '1':
		k += 1
		if k >= n:
			break
	cnt += 1
	k = A.find('0', k)
if cnt == 0:
	print(0)
else:
	print((cnt - 1) * min(x, y) + y)


def segments(s, x, y):
	count = s.count('10') + s.startswith('0')
	if count:
		return (count - 1) * min(x, y) + y
	return 0
(n, X, Y) = [int(i) for i in input().split()]
t = input()
print(segments(t, X, Y))


(n, x, y) = map(int, input().split())
s = input()
c = 0
for i in range(1, n):
	if s[i] == '1' and s[i - 1] == '0':
		c += 1
if s[-1] == '0':
	c += 1
if c == 0:
	print(0)
elif x >= y:
	print(c * y)
else:
	print((c - 1) * x + y)


def main():
	(n, x, y) = list(map(int, input().split()))
	string = input()
	numbers = [int(i) for i in string]
	zero_blocks = 0
	last_number = -1
	for number in numbers:
		if last_number == 0 and number == 1:
			zero_blocks += 1
		last_number = number
	if numbers[-1] == 0:
		zero_blocks += 1
	if zero_blocks == 0:
		print(0)
		return
	if y <= x:
		print(y * zero_blocks)
		return
	else:
		print(x * (zero_blocks - 1) + y)
		return
main()


a = input().split()
n = int(a[0])
x = int(a[1])
y = int(a[2])
a = input()
groups = 0
add = True
for i in range(n):
	if add == True and a[i] == '0':
		groups += 1
		add = False
	if a[i] == '1':
		add = True
tot1 = groups * y
tot2 = (groups - 1) * x + y
if abs(tot1) > abs(tot2):
	print(tot2)
else:
	print(tot1)


(n, x, y) = [int(x) for x in input().split()]
l = list(input())
l = ['1'] + l + ['1']
num = 0
for i in range(len(l) - 1):
	if l[i] == '1' and l[i + 1] == '0':
		num += 1
l = l[1:-1]
num1 = num * y
num2 = max(0, num * x - x + y)
print(min(num1, num2))


[n, x, y] = [int(x) for x in input().split()]
A = input()
if len(A) == 1:
	if A[0] == '1':
		print('0')
	else:
		print(y)
else:
	c = 0
	if A[0] == '0':
		c = 1
	for i in range(1, len(A)):
		if A[i] == '0' and A[i - 1] == '1':
			c += 1
	m = y * c
	for i in range(1, c):
		temp = x * i + y * (c - i)
		if temp < m:
			m = temp
	print(m)


import math
import sys

def count_inversions(_str):
	inversions = 0
	end = 0
	start = 0
	for i in range(len(_str) - 1, -1, -1):
		if _str[i] == '0':
			end = i
			break
	for i in range(len(_str)):
		if _str[i] == '0':
			start = i
			break
	i = start
	while i <= end:
		if _str[i] == '1':
			for j in range(i, end + 1):
				if _str[j] == '0':
					inversions = inversions + 1
					i = j
					break
		i = i + 1
	return inversions

def main():
	(n, reverse_cost, flip_cost) = (int(x) for x in sys.stdin.readline().strip().split())
	_str = list(sys.stdin.readline().strip())
	inversions = count_inversions(_str)
	if len(list(filter(lambda x: x == '0', _str))) == 0:
		sys.stdout.write('0')
		return
	if len(list(filter(lambda x: x == '1', _str))) == 0:
		sys.stdout.write(str(flip_cost))
		return
	sys.stdout.write(str(inversions * min(reverse_cost, flip_cost) + flip_cost))
main()


(n, x, y) = (int(x) for x in input().split())
s = input()
k = s.count('01')
if s.endswith('0'):
	k += 1
if k == 0:
	print(0)
elif y < x:
	print(y * k)
else:
	print(x * (k - 1) + y)


def scanf(t=int):
	return list(map(t, input().split()))
(n, x, y) = scanf()
m = input()
p = m.count('10')
if m[0] == '0':
	p += 1
print(y + (p - 1) * min(x, y) if p else 0)


def main():
	(n, x, y) = map(int, input().split())
	(s, zo, a) = (input(), [0, 0], ' ')
	for b in s:
		if a != b:
			zo[b == '1'] += 1
			a = b
	(z, o) = zo
	if s[0] == '1':
		o -= 1
	if s[-1] == '1':
		o -= 1
	if o < 0:
		o = 0
	print(min(z * y, o * x + y))
main()


(n, x, y) = map(int, input().split())
ans = 0
s = input()
for i in range(n - 1):
	if s[i] == '0' != s[i + 1]:
		ans += 1
if s[n - 1] == '0':
	ans += 1
if ans == 0:
	print(0)
else:
	print((ans - 1) * min(x, y) + y)


(n, x, y) = list(map(int, input().split()))
s = input()
(cnt, tmp) = (0, 0)
for i in s:
	if i == '1':
		if tmp:
			cnt += 1
		tmp = 0
	else:
		tmp += 1
if tmp:
	cnt += 1
if cnt > 0:
	print(min(x, y) * (cnt - 1) + y)
else:
	print(0)


R = lambda : map(int, input().split())
(n, x, y) = R()
s = input()
if n == 1:
	print(y if s[0] == '0' else 0)
	exit(0)
blks = sum((s[i] == '1' and s[i + 1] == '0' for i in range(n - 1))) - (s[-1] == '0')
mvs = blks
if s[0] == s[-1] == '0':
	mvs += 1
elif s[0] == s[-1] == '1' and mvs > 0:
	mvs -= 1
print(min(mvs * x + y, (blks + (s[0] == '0') + (s[-1] == '0')) * y))


(n, x, y) = list(map(int, input().split(' ')))
s = list(map(int, list(input())))
t = []
last0 = False
isfirst = True
for i in s:
	if i == 0:
		if isfirst:
			t.append(i)
			isfirst = False
			last0 = True
		elif last0:
			continue
		else:
			last0 = True
			t.append(i)
	else:
		if isfirst:
			t.append(i)
			isfirst = False
			last0 = False
		if not last0:
			continue
		else:
			last0 = False
			t.append(i)
if x < y:
	s = 0
	for i in t:
		if i == 0:
			s += 1
	if s != 0:
		print((s - 1) * x + y)
	else:
		print(0)
else:
	s = 0
	for i in t:
		if i == 0:
			s += 1
	print(s * y)


def solution():
	(n, x, y) = map(int, input().split())
	s = input()
	s = '1' + s + '1'
	flag = 0
	cnt = 0
	for i in range(1, len(s)):
		if s[i - 1] == '1' and s[i] == '0':
			cnt += 1
	if cnt == 0:
		print(0)
	elif x < y:
		print((cnt - 1) * x + y)
	else:
		print(cnt * y)
solution()


(n, x, y) = [int(i) for i in input().split()]
s = [int(i) for i in input()]
lis = []
ind = -1
flag0 = flag1 = 0
for i in range(n):
	if s[i] == 0 and flag0 == 0:
		ind = i
		flag0 = 1
		flag1 = 0
	elif s[i] == 1 and flag1 == 0:
		if ind != -1:
			lis.append(ind)
		flag1 = 1
		flag0 = 0
if flag1 == 0 and flag0 == 1:
	if ind != -1:
		lis.append(ind)
x1 = len(lis)
if x1 == 0:
	print(0)
else:
	ans = (x1 - 1) * min(x, y) + y
	print(ans)


(n, x, y) = map(int, input().split())
a = input()
if n == 1 and a[0] == '0':
	print(y)
elif n == 1:
	print('0')
else:
	mx = 0
	for i in range(n - 1):
		if a[i] == '0' and a[i + 1] == '1' or (i == n - 2 and (a[i] == '0' or a[i + 1] == '0')):
			mx += y
	mx2 = 0
	change = 0
	for i in range(n - 1):
		if a[i] == '1' and a[i + 1] == '0' and (change != 0):
			mx2 += x
		if a[i] == '0':
			change = 1
	mx2 += y
	print(min(mx, mx2))


x = str(input())
x = x.split(' ')
x = [int(g) for g in x if g != '']
l = str(input())
c = 0
t = 0
f = l[0]
for i in range(x[0]):
	if f != l[i]:
		f = l[i]
		c += 1
f = l[0]
if c != 0:
	t = 1
if f == l[x[0] - 1]:
	if f == '0':
		k = (c + 2) / 2
	if f == '1':
		k = c / 2
else:
	k = (c + 1) / 2
if t == 1:
	if x[1] < x[2]:
		print(int((k - 1) * x[1] + x[2]))
	else:
		print(int(k * x[2]))
elif f == '0':
	print(x[2])
else:
	print(0)


(n, x, y) = map(int, input().split())
s = input()
c = 0
(ans1, ans2) = (0, 0)
for i in range(n - 1):
	if s[i] == '0' and s[i + 1] == '1':
		c += 1
if s[n - 1] == '0':
	c += 1
if c == 0:
	print(0)
else:
	ans1 = x * (c - 1) + y
	ans2 = (c - 1) * y + y
	print(min(ans1, ans2))


import collections
from functools import cmp_to_key
import math
import sys

def getIntList():
	return list(map(int, input().split()))
import bisect
try:
	import numpy
	dprint = print
	dprint('debug mode')
except ModuleNotFoundError:

	def dprint(*args, **kwargs):
		pass

def makePair(z):
	return [(z[i], z[i + 1]) for i in range(0, len(z), 2)]

def memo(func):
	cache = {}

	def wrap(*args):
		if args not in cache:
			cache[args] = func(*args)
		return cache[args]
	return wrap

@memo
def comb(n, k):
	if k == 0:
		return 1
	if n == k:
		return 1
	return comb(n - 1, k - 1) + comb(n - 1, k)
(N, x, y) = getIntList()
zs = input()
total = 0
for i in range(N):
	if zs[i] == '1':
		continue
	if i == 0 or zs[i - 1] == '1':
		total += 1
dprint(total)
if total == 0:
	print(0)
elif x > y:
	print(y * total)
else:
	print(y + (total - 1) * x)


(n, x, y) = map(int, input('').split(' '))
texte = input('').split('1')
espace = texte.count('')
print(max(0, min((len(texte) - espace - 1) * x + y, (len(texte) - espace) * y)))


(n, x, y) = map(int, input().split())
s = input()
a = b = 0
for i in s + '1':
	if i == '1':
		a += b
		b = 0
	else:
		b = 1
print(min(max(0, (a - 1) * x + y), a * y))


def r(a, b):
	ans = a // b
	if a % b != 0:
		ans += 1
	return ans
(n, x, y) = map(int, input().split())
a = list(input()) + ['1']
count = 0
for i in range(1, n + 1):
	if a[i] == '1' and a[i - 1] == '0':
		count += 1
ans = 999999999999999999
if count == 0:
	print(0)
	exit()
for i in range(count):
	ans = min(ans, min(x, y) * i + y * (count - i))
print(ans)


(n, x, y) = map(int, input().split())
s = input()
pr = '2'
s2 = ''
nol = 0
ed = 0
for i in range(n):
	if s[i] != pr:
		pr = s[i]
		s2 += s[i]
		if int(s[i]) == 0:
			nol += 1
		else:
			ed += 1
if y <= x or nol == 0:
	print(nol * y)
else:
	print(y + max(0, nol - 1) * x)


(n, cost_rev, cost_inv) = [int(i) for i in input().split()]
a = input()
lst = []
for i in range(len(a)):
	lst.append(int(a[i]))
count = 0
flag = False
for i in range(len(a)):
	if lst[i] == 0 and flag == False:
		count += 1
		flag = True
	if lst[i] == 1:
		flag = False
if count > 0:
	cost = min((count - 1) * cost_rev + cost_inv, count * cost_inv)
else:
	cost = 0
print(cost)


(n, x, y) = (int(s) for s in input().split())
str_ = input()
if str_[0] == '0':
	number_of_zero_sequence = 1
else:
	number_of_zero_sequence = 0
for i in range(1, n):
	if str_[i] == '0' and str_[i - 1] != '0':
		number_of_zero_sequence += 1
ans = 0
if x > y:
	ans = number_of_zero_sequence * y
elif number_of_zero_sequence != 0:
	ans = (number_of_zero_sequence - 1) * x + y
print(ans)


import os
import sys
from io import BytesIO, IOBase
from itertools import groupby

def main():
	(n, c1, c2) = map(int, input().split(' '))
	s = input()
	a = [[x, len(list(y))] for (x, y) in groupby(s)]
	n = len(a)
	cnt = 0
	for x in range(n):
		if a[x][0] == '0':
			cnt += 1
	ans = int(1e+100)
	for x in range(1, cnt + 1):
		ans = min(ans, (cnt - x) * c1 + x * c2)
	print(0 if ans == int(1e+100) else ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, x, y) = map(int, input().split())
a = '1' + input()
if '0' not in a:
	print(0)
else:
	cur = -1
	result = y - min(x, y)
	while True:
		cur = a.find('10', cur + 1)
		if cur == -1:
			break
		result += min(x, y)
	print(result)


(n, x, y) = map(int, input().split())
a = input()
count = 0
for i in range(n):
	if i == 0 and a[i] == '0':
		count += 1
	if i != 0 and a[i] == '0' and (a[i - 1] == '1'):
		count += 1
if count == 0:
	print(0)
else:
	print((count - 1) * min(x, y) + y)


(n, cx, cy) = [int(x) for x in input().split()]
s = input()
g0 = 0
for i in range(n):
	if s[i] == '0' and (i == 0 or s[i - 1] == '1'):
		g0 += 1
if g0 == 0:
	print('0')
else:

	def cost(x):
		return (g0 - x) * cy + cx * x
	print(min(cost(g0 - 1), cost(0)))


(n, x, y) = map(int, input().split())
a = input()
if '0' not in a:
	print(0)
else:
	number_of_zero_groups = 0
	curr = a[0]
	if curr == '0':
		number_of_zero_groups += 1
	for e in a[1:]:
		if e == '0' and curr == '1':
			number_of_zero_groups += 1
		curr = e
	print((number_of_zero_groups - 1) * min(x, y) + y)


from sys import stdin, stdout

def main():
	(n, x, y) = [int(i) for i in stdin.readline().split()]
	a = stdin.readline()
	prev = '1'
	count = 0
	for i in range(n):
		if a[i] == '0' and prev == '1':
			count += 1
		prev = a[i]
	if count == 0:
		print(0)
	else:
		print(y + (count - 1) * min(x, y))
main()


from sys import *
from math import *
from bisect import *
(n, x, y) = map(int, stdin.readline().split())
s = input()
c = 0
for i in range(1, n):
	if s[i] == '1' and s[i - 1] == '0':
		c += 1
if s[-1] == '0':
	c += 1
if c == 0:
	print(0)
elif x >= y:
	print(c * y)
else:
	print((c - 1) * x + y)


(n, x, y) = map(int, input().split())
s = list(input())
arr = [s[0]]
for i in range(1, n):
	if s[i] != s[i - 1]:
		arr.append(s[i])
if len(arr) == 1 and arr[0] == '1':
	print(0)
	exit(0)
c = arr.count('0')
xarr = [0]
yarr = [y]
for i in range(1, c):
	xarr.append(xarr[-1] + x)
	yarr.append(yarr[-1] + y)
yarr.reverse()
print(min(map(lambda o: o[0] + o[1], zip(xarr, yarr))))


(n, x, y) = map(int, input().split())
s = list(input())
if s.count('0') == 0:
	print(0)
	exit()
s1 = s[:]
grp = 0
for i in range(1, n):
	if s[i] == '1' and s[i - 1] == '0':
		grp += 1
if s[-1] == '0':
	grp += 1
ans = min((grp - 1) * x + y, grp * y)
print(ans)


(a, b, c) = map(int, input().split())
n = list(input())
n = n[::-1]
l = 0
w = 0
p = min(b, c)
i = 0
while n[i] == '0':
	i += 1
	w = 1
	if i == a:
		break
while i < a:
	if n[i] == '0':
		w += 1
		l += b
		while n[i] == '0':
			i += 1
			if i == a:
				break
	elif n[i] == '1':
		while n[i] == '1':
			i += 1
			if i == a:
				break
l += c
if len(set(n)) == 1 and list(set(n))[0] == '1':
	l = 0
print(min(l, p * (w - 1) + c))


from __future__ import print_function
from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n, rev, flip) = gil()
a = gbs()
cnt = 0
ans = 0
while a:
	while a and a[-1]:
		a.pop()
	if a and a[-1] == 0:
		cnt += 1
	while a and a[-1] == 0:
		a.pop()
if cnt:
	ans = min(flip * cnt, flip + (cnt - 1) * rev)
print(ans)


(n, x, y) = map(int, input().split())
line = input()
temp = line.split('1')
cnt = 0
for i in temp:
	if len(i) > 0:
		cnt += 1
print(min(y * cnt, abs(y + x * (cnt - 1))))


(n, x, y) = map(int, input().split())
io = '1'
c = 0
for i in input():
	if i == '0':
		c += int(io != i)
	io = i
if c > 0:
	print(min(y * c, y + x * (c - 1)))
else:
	print(0)


(n, a, b) = map(int, input().split())
s = input()
k = sum(map(lambda x, y: x == '1' and y == '0', s, s[1:]))
k += s[0] == '0'
print(b + min(a, b) * (k - 1) if k else 0)


(n, a, y) = input().strip().split(' ')
(n, a, y) = [int(n), int(a), int(y)]
bin_str = str(input())
p = 0
flag = 0
for x in range(0, len(bin_str)):
	if bin_str[x] == '0':
		flag = 1
	elif bin_str[x] == '1' and flag == 1:
		flag = 0
		p += 1
if flag == 1 and bin_str[x - 1]:
	p += 1
if p == 0:
	print('0')
else:
	ans = (p - 1) * min(a, y) + y
	print(ans)


(n, x, y) = [int(x) for x in input().split()]
xs = input().strip()
from itertools import groupby
count = sum((1 for (g, _) in groupby(xs) if g == '0'))
ans = count * y
for i in range(count):
	ans = min(ans, i * x + (count - i) * y)
print(ans)


(n, x, y) = list(map(int, input().strip().split(' ')))
s = input()
groups = 0
if s[0] == '0':
	groups += 1
for b in range(1, n):
	if s[b] == '0' and s[b - 1] == '1':
		groups += 1
if groups == 0:
	print(0)
else:
	print((groups - 1) * min(x, y) + y)


inp = input().split()
n = int(inp[0])
x = int(inp[1])
y = int(inp[2])
a = input().split('1')
zeros = 0
for z in a:
	if len(z) > 0:
		zeros += 1
print(max(0, min(zeros * y, y + (zeros - 1) * x)))


from __future__ import print_function
import sys
import math
import os.path
import random
from copy import deepcopy
from functools import reduce
from collections import Counter, ChainMap, defaultdict
from itertools import cycle, chain
from queue import Queue, PriorityQueue
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, nlargest, nsmallest
import bisect
from statistics import mean, mode, median, median_low, median_high
sys.setrecursionlimit(10 ** 9)

def log(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def ni():
	return map(int, input().split())

def nio(offset):
	return map(lambda x: int(x) + offset, input().split())

def nia():
	return list(map(int, input().split()))

def toString(aList, sep=' '):
	return sep.join((str(x) for x in aList))

def toMapInvertIndex(aList):
	return {k: v for (v, k) in enumerate(aList)}

def sortId(arr):
	return sorted(range(arr), key=lambda k: arr[k])
(n, x, y) = ni()
s = input()
c0 = 1 if s[0] == '0' else 0
c0 += s.count('10')
if c0 == 0:
	print(0)
elif c0 == 1:
	print(y)
else:
	print(min((c0 - 1) * x + y, c0 * y))


(n, x, y) = map(int, input().split())
a = '1' + input()
c = 0
for i in range(1, n + 1):
	if a[i] == '0' and a[i - 1] == '1':
		c += 1
print(min(c * y, max(0, y + (c - 1) * x)))


(n, x, y) = map(int, input().split())
s = input()
c = 0
f = 0
for i in range(n):
	if s[i] == '0':
		if not f:
			c += 1
			f = 1
	else:
		f = 0
if c == 0:
	print(0)
	exit(0)
ans = y + (c - 1) * min(x, y)
print(ans)


(n, x, y) = map(int, input().split())
ss = input().strip()
L = len(ss)
i = 0
last = -1
cnt = 0
while i < L:
	if ss[i] == '1':
		if last == 0:
			cnt += 1
		last = 1
	else:
		last = 0
	i += 1
if ss[L - 1] == '0':
	cnt += 1
ans = 0
if x < y:
	ans = (cnt - 1) * x + y
else:
	ans = cnt * y
if cnt == 0:
	ans = 0
print(int(ans))


from itertools import groupby
(noc, x, y) = [int(x) for x in input().split()]
s = input()
sg = groupby(s)
sg = [(k, list(g)) for (k, g) in sg if set(list(g)) == {'0'}]
lsg = len(sg)
ans = (len(sg) - 1) * min(x, y) + y
print(0 if lsg == 0 else ans)


(n, x, y) = input().split()
(n, x, y) = (int(n), int(x), int(y))
amount = 0
(first, second, third) = (False, False, False)
a = str(input())
reset = True
for i in a:
	if i == '0' and reset:
		amount += 1
		reset = False
	elif i == '1':
		reset = True
if amount == 0:
	print(0)
else:
	print(min(amount * y, (amount - 1) * x + y))


import re
(n, a, b) = map(int, input().split())
inp = input()
inp = re.sub('0+', '0', inp)
inp = re.sub('1+', '1', inp)
count = 0
for char in inp:
	if char == '0':
		count += 1
print(max(0, min(b * count, a * (count - 1) + b)))


(n, x, y) = map(int, input().split())
s = input().strip()
from itertools import groupby
b = [1 if k == '1' else 0 for (k, g) in groupby(s)]
dp = [0] * len(b)
dp[0] = y if b[0] == 0 else 0
for i in range(1, len(b)):
	if b[i] == 0:
		dp[i] = dp[i - 1] + y
		if i >= 2:
			dp[i] = min(dp[i], x + dp[i - 2])
	else:
		dp[i] = dp[i - 1]
print(dp[-1])


(n, x, y) = input().split()
n = int(n)
x = int(x)
y = int(y)
ch = input()
cnt = 0
if ch[0] == '0':
	cnt += 1
for i in range(1, len(ch)):
	if ch[i] == '0' and ch[i - 1] == '1':
		cnt += 1
ans = 0
if cnt > 0:
	ans = y
	cnt -= 1
if x < y:
	ans += x * cnt
else:
	ans += y * cnt
print(ans)


(n, x, y) = map(int, input().split())
s = input()
blocks = 0
ins = False
for char in s:
	if char == '0':
		if not ins:
			ins = True
			blocks += 1
	elif ins:
		ins = False
if blocks == 0:
	print(0)
else:
	print(y + (blocks - 1) * min(x, y))


(n, x, y) = map(int, input().split())
a = input()
cnt = 0
prev = '1'
for ai in a:
	if prev == '1' and ai == '0':
		cnt += 1
	prev = ai
if cnt == 0:
	print(0)
else:
	print(min(x, y) * (cnt - 1) + y)


(n, x, y) = map(int, input().split())
a = input() + '1'
cnt = a.count('01')
if cnt == 0:
	print(0)
else:
	print((cnt - 1) * min(x, y) + y)


[n, x, y] = map(int, input().strip().split())
a = input().strip() + '1'
k = a.count('01')
if k == 0:
	print(0)
else:
	print((k - 1) * min(x, y) + y)


(n, x, y) = map(int, input().split())
s = input()
c = s.count('10')
if s[0] == '0':
	c += 1
ans = 10 ** 18
if c == 0:
	print(0)
else:
	for i in range(c):
		ans = min(ans, x * i + y * (c - i))
	print(ans)


nxy = list(map(int, input().split(' ')))
s = input()
if s.find('0') == -1:
	print('0')
	exit()
t = 0
ame = 0
if s[0] == '1':
	t = s.find('0')
completed = False
r = t
while not completed:
	t = s.find('1', r + 1)
	if t != -1:
		ame += 1
		r = t
	else:
		ame += 1
		break
	t = s.find('0', r + 1)
	if t != -1:
		r = t
	else:
		break
if (ame - 1) * nxy[1] + nxy[2] < ame * nxy[2]:
	print((ame - 1) * nxy[1] + nxy[2])
else:
	print(ame * nxy[2])


(n, x, y) = map(int, input().split())
seq = input()
segments = 0
flag = False
for i in seq:
	if i == '0':
		if flag:
			continue
		else:
			flag = True
	elif flag:
		segments += 1
		flag = False
	else:
		continue
if flag:
	segments += 1
	flag = False
cost = segments * y
for i in range(segments):
	currcost = i * x + (segments - i) * y
	if currcost < cost:
		cost = currcost
print(cost)


(n, x, y) = map(int, input().split())
p = len(input().replace('1', ' ').split())
print([0, (p - 1) * min(x, y) + y][p > 0])


(n, x, y) = map(int, input().split())
u = list(map(int, input()))
d0 = 0
k0 = 0
for i in range(n):
	if k0 == 1 and u[i] == 1:
		d0 += 1
		k0 = 0
	elif u[i] == 0:
		k0 = 1
if k0 == 1:
	d0 += 1
if d0 == 0:
	p = 0
else:
	p = (d0 - 1) * min(x, y) + y
print(p)


(n, x, y) = map(int, input().split())
s = input()
lst = -1
cnt = 0
for i in s:
	if i == '1':
		if lst == 0:
			cnt += 1
			lst = -1
	else:
		lst = 0
if s[n - 1] == '0':
	cnt += 1
if cnt == 0:
	exit(print(0))
ans = 0
if x >= y:
	ans = y * cnt
else:
	ans = (cnt - 1) * x + y
print(ans)


(n, x, y) = list(map(int, input().split()))
a = input()
k = 0
for i in range(n):
	if i == 0 or a[i] != a[i - 1]:
		if a[i] == '0':
			k += 1
if k == 0:
	print(0)
else:
	print(min([x * r + (k - r) * y for r in range(k)]))


(n, x, y) = map(int, input().split())
c = input()
f = 0
t = 0
for i in range(n):
	if c[i] == '0':
		if not f:
			t += 1
			f = 1
	else:
		f = 0
if not t:
	print(0)
else:
	print(y + (t - 1) * min(x, y))


import sys
(n, x, y) = map(int, sys.stdin.readline().split())
s = input()
a = 0
for i in range(n - 1):
	if s[i] == '0':
		if s[i] != s[i + 1]:
			a += 1
if s[n - 1] == '0':
	a += 1
if a == 0:
	print(0)
else:
	print((a - 1) * min(x, y) + y)


l = [int(x) for x in input().split()]
n = input()
x = 0
y = 0
if len(set(n)) == 1:
	if n[0] == '1':
		print(0)
	else:
		print(l[2])
else:
	for i in range(0, len(n)):
		if i == 0:
			if n[0] == '0':
				x += 1
				y += 1
				continue
		if n[i] == '1':
			continue
		if n[i] == '0' and n[i - 1] == '0':
			continue
		if n[i] == '0' and n[i - 1] == '1':
			x += 1
			y += 1
	costy = y * l[2]
	costx = (x - 1) * l[1] + l[2]
	print(min(costy, costx))


import sys
input = sys.stdin.readline
(n, x, y) = map(int, input().split())
a = input().strip()
things = 0
b = 0
for i in range(n):
	if b == 0:
		if a[i] == '0':
			b = 1
	elif a[i] == '1':
		things += 1
		b = 0
things += b
if things == 0:
	print(0)
else:
	print(min(x, y) * (things - 1) + y)


(n, x, y) = tuple(map(int, input().split()))
str = input()
num = 0
i = 0
while i < len(str):
	if str[i] == '0':
		j = i + 1
		num += 1
		while j < len(str) and str[j] == '0':
			j += 1
		i = j
	i += 1
if n * '1' == str:
	print(0)
elif x <= y:
	print((num - 1) * x + y)
else:
	print(num * y)


(n, x, y) = map(int, input().split())
s = input()
if '0' not in s:
	print(0)
elif '1' not in s:
	print(y)
else:
	zero_start = s[0] == '0'
	zero_end = s[-1] == '0'
	ones_groups = 0
	i = 0
	while i < n:
		found = False
		while i < n and s[i] == '1':
			found = True
			i += 1
		if found:
			ones_groups += 1
		i += 1
	replace = max(0, ones_groups - (0 if zero_start else 1) - (0 if zero_end else 1)) * x + y
	invert = (ones_groups - 1 + (1 if zero_start else 0) + (1 if zero_end else 0)) * y
	print(min(replace, invert))


import time
(n, x, y) = (int(i) for i in input().split())
a = input()
start = time.time()
I = 0
while a[I] == '1':
	I += 1
	if I == n:
		break
flag = 1
N = 0
for i in range(I, n):
	if flag == 0:
		if a[i] == '1':
			flag = 1
	elif a[i] == '0':
		flag = 0
		N += 1
if N == 0:
	print(0)
elif x > y:
	print(N * y)
else:
	print(y + x * (N - 1))
finish = time.time()


(n, x, y) = map(int, input().split())
s = input()
t = s.split('1')
num = 0
for i in range(len(t)):
	if len(t[i]) > 0:
		num += 1
if num == 0:
	print(0)
else:
	print(min(x, y) * (num - 1) + y)


def numberofgroupsofzeroes(s):
	count = 0
	if s[len(s) - 1] == '0':
		count = 1
	for i in range(0, len(s) - 1):
		if s[i] == '0' and s[i + 1] == '1':
			count += 1
	return count

def minimum(num1, num2):
	if num1 <= num2:
		return num1
	else:
		return num2
(n, x, y) = [int(e) for e in input().split()]
a = input()
groupnum = numberofgroupsofzeroes(a)
if groupnum == 0:
	print(0)
else:
	answer = (groupnum - 1) * minimum(x, y) + y
	print(answer)


(n, x, y) = [int(j) for j in input().split()]
a = input().split('1')
p = 0
for i in a:
	if '0' in i:
		p += 1
if p == 0:
	print(0)
else:
	print((p - 1) * min(x, y) + y)


import re
R = lambda : map(int, input().split())
(n, x, y) = R()
s = input()
s = re.sub('1+', '1', s)
s = re.sub('0+', '0', s)
s = re.sub('^1', '', s)
s = re.sub('1$', '', s)
n = (len(s) + 1) // 2
ans = n * y
for i in range(n):
	ans = min(ans, i * x + (n - i) * y)
print(ans)


import re
cost = 0
inp = input().split(' ')
string = input()
count0 = re.findall('0+', string)
if count0 and int(inp[1]) < int(inp[2]):
	cost += (len(count0) - 1) * int(inp[1]) + int(inp[2])
else:
	cost += len(count0) * int(inp[2])
print(cost)


(n, x, y) = map(int, input().split())
s = input()
count = 0
i = 0
while i < n:
	j = i
	while j < n and s[j] == s[i]:
		j += 1
	if s[i] == '0':
		count += 1
	i = j
ans = 0
if count > 0:
	ans = min(x, y) * (count - 1) + y
print(ans)


def so(l):
	l = l.replace('11', '1')
	return l
(n, x, y) = map(int, input().split())
l = input()
if '0' not in l:
	print(0)
else:
	while '11' in l:
		l = so(l)
	l = l.split('1')
	if l[0] == '':
		l.remove('')
	if l[-1] == '':
		l.pop()
	a = len(l) - 1
	ans1 = (a + 1) * y
	ans2 = a * x + y
	print(min(ans1, ans2))


def readline():
	return map(int, input().split())

def main():
	(n, x, y) = readline()
	line = input()
	one = line.count('10')
	zero = line.count('01')
	assert abs(one - zero) < 2
	if one != zero:
		segments_of_zeros = max(one, zero)
	else:
		segments_of_zeros = one + (line[0] == '0')
	print((segments_of_zeros - 1) * min(x, y) + y if segments_of_zeros else 0)
main()


(n, x, y) = list(map(int, input().split()))
s = input()
p = 0
g = False
for i in s:
	if i == '0':
		if not g:
			p += 1
			g = True
	else:
		g = False
if p == 0:
	print(0)
else:
	print((p - 1) * min(x, y) + y)


a = list(map(int, input().split()))
n = a[0]
x = a[1]
y = a[2]
s = input()
c = 0
f = 0
p = s[0]
b = s[0]
if s[0] == '0':
	f = 1
for i in range(1, n):
	if s[i] != p:
		c += 1
		p = s[i]
	if f == 0:
		if s[i] == '0':
			f = 1
e = p
ans1 = c // 2 * x
if f == 1:
	ans1 += y
if b == e and b == '1' and (f == 1):
	ans1 -= x
ans2 = c // 2 * y
if b != e or b != '1':
	ans2 += y
print(min(ans1, ans2))


(n, x, y) = [int(i) for i in input().split()]
s = input()
first = 0
sec = 0
flag = 0
for i in range(len(s)):
	if s[i] == '1' and flag == 1:
		first += 1
		flag = 0
	if s[i] == '0':
		flag = 1
if flag == 1:
	first += 1
if first == 0:
	print(0)
else:
	first -= 1
	cost = y
	cost += first * min(x, y)
	print(cost)


(n, x, y) = map(int, input().split())
s = input()
l = -1
r = -1
ans = []
for i in range(n):
	if s[i] == '0':
		ans.append(i)
if len(ans) == 0:
	print(0)
else:
	a = 1
	for i in range(1, len(ans)):
		if ans[i] != ans[i - 1] + 1:
			a += 1
	print((a - 1) * min(x, y) + y)


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import string
import sys
import time
sys.setrecursionlimit(99999)
(n, x, y) = map(int, input().split())
s = input()
p = 0
for (k, v) in itertools.groupby(s):
	if k == '0':
		p += 1
if not p:
	print(0)
else:
	ans = p * y
	ans = min(ans, y + (p - 1) * x)
	print(ans)


(n, x, y) = map(int, input().split())
s = input()
cnt = 0
i = 0
while i < n:
	if s[i] == '0':
		cnt += 1
		while i < n and s[i] == '0':
			i += 1
	i += 1
ans = 10 ** 18
for i in range(cnt, 0, -1):
	val = i * y + (cnt - i) * x
	ans = min(ans, val)
if ans == 10 ** 18:
	print(0)
else:
	print(ans)


(n, x, y) = map(int, input().split())
k = sum((1 for i in input().split('1') if i))
ans = k * y
for i in range(1, k):
	ans = min(ans, i * x + (k - i) * y)
print(ans)


(n, x, y) = map(int, input().split(' '))
s = input()
isolated = 0
ones = 0
last = '1'
for digit in s:
	if digit == '1' and last == '0':
		isolated += 1
	if digit == '0':
		ones += 1
	last = digit
if last == '0':
	isolated += 1
if ones == 0:
	print(0)
else:
	print(min(isolated * y, (isolated - 1) * x + y))


def main():
	(n, x, y) = map(int, input().split())
	s = input()
	p = ''
	t = []
	for c in s:
		if c != p:
			t.append(c)
		p = c
	k = 0
	for c in t:
		if c == '0':
			k += 1
	if k == 0:
		print(0)
	elif k == 1:
		print(y)
	elif x < y:
		print(x * (k - 1) + y)
	else:
		print(k * y)
main()


header = input()
header = [int(i) for i in header.split()]
n = header[0]
revCost = header[1]
opCost = header[2]
numsData = input()
clusters = 0
i = 0
complete = False
while numsData[i] == '1':
	i += 1
	if i >= len(numsData):
		complete = True
		break
if not complete:
	while True:
		while numsData[i] == '0':
			i += 1
			if i >= len(numsData):
				break
		if i >= len(numsData):
			break
		while numsData[i] == '1':
			i += 1
			if i >= len(numsData):
				break
		if i >= len(numsData):
			break
		clusters += 1
	zeroClusters = clusters
	if numsData[0] == '0':
		zeroClusters += 1
	if numsData[0] == '1':
		zeroClusters += 1
	ansOne = clusters * revCost + opCost
	ansTwo = zeroClusters * opCost
	print(min(ansOne, ansTwo))
else:
	print(0)


(n, x, y) = [int(s) for s in input().split(' ')]
a = input()
z = len([t for t in a.split('1') if t])
ans = max(min(z * y, y + (z - 1) * x), 0)
print(ans)


(n, x, y) = map(int, input().split())
s = input()
k = 0
if s[0] == '0':
	for i in range(n - 1):
		if s[i] + s[i + 1] == '01':
			k += 1
	if s[-1] == '0':
		k += 1
else:
	for i in range(n - 1):
		if s[i] + s[i + 1] == '10':
			k += 1
if k == 0:
	print(0)
else:
	print(min(k * y, (k - 1) * x + y))


(n, x, y) = map(int, input().split())
s = input().strip()
zero = 0
if s.count('0') == 0:
	print(0)
	exit()
cnt = sum([1 for x in s.split('1') if len(x) > 0])
print((cnt - 1) * min(x, y) + y)


(n, x, y) = map(int, input().split())
a = input()
a = a.strip('1')
n = len(a)
c = 0
i = 0
while i < n:
	try:
		i1 = a.index('1', i)
		if x < y:
			try:
				i = a.index('0', i1)
			except:
				i = n
			c += x
		else:
			i = a.index('0', i1)
			c += y
	except:
		i = n
		c += y
print(c)


(n, y, x) = map(int, input().split())
a = input()
i = 0
cnt = 0
while i < n:
	while i < n and a[i] == '1':
		i += 1
	if i == n:
		break
	cnt += 1
	while i < n and a[i] == '0':
		i += 1
if cnt == 0:
	print(0)
else:
	print(min(cnt * x, (cnt - 1) * y + x))


import re
(_, x, y) = map(int, input().split())
n = len(re.findall('0+', input()))
print(y + (n - 1) * min(x, y) if n else 0)


(n, x, y) = (int(i) for i in input().split())
s = input()
on = False
c = 0
for e in s:
	if e == '0' and (not on):
		on = True
		c += 1
	elif e == '1':
		on = False
print(max(0, min((c - 1) * x + y, c * y)))


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	(n, x, y) = li()
	s = input().strip().split('1')
	c = 0
	for i in s:
		if i != '':
			c += 1
	if c == 0:
		print(0)
		return
	print(min((c - 1) * x + y, c * y))
for _ in range(1):
	case()


(n, x, y) = map(int, input().split())
s = input()
count = 0
if s[0] == '1':
	tp = -1
else:
	tp = 0
	count = 1
for i in range(1, n):
	if s[i] == '0':
		if tp == -1:
			tp = 0
			count += 1
	elif tp == 0:
		tp = -1
if x >= y:
	print(count * y)
elif count >= 2:
	print((count - 1) * x + y)
elif count == 1:
	print(y)
else:
	print(0)


(n, x, y) = map(int, input().split())
s = input()
chains = 0
zero = False
for i in range(n):
	if not zero and s[i] == '0':
		zero = True
	elif not zero and s[i] == '1':
		continue
	elif zero and s[i] == '0':
		continue
	elif zero and s[i] == '1':
		chains += 1
		zero = False
if zero:
	chains += 1
if chains == 0:
	print(0)
else:
	min_cost = 99999999999999999999999999
	for n_invert in range(1, chains + 1):
		n_reverse = chains - n_invert
		cost = n_reverse * x + n_invert * y
		min_cost = min(min_cost, cost)
	print(min_cost)


(n, x, y) = map(int, input().split())
a = input()
cnt = 0
i = 0
while i < n:
	if a[i] == '0':
		cnt += 1
		while a[i] == '0' and i < n - 1:
			i += 1
	i += 1
if not cnt:
	print(0)
	exit()
ans = cnt * y
for i in range(1, cnt + 1):
	ans = min(ans, i * y + (cnt - i) * x)
print(ans)


from copy import deepcopy
import itertools
from bisect import bisect_left
from bisect import bisect_right
import math
from collections import deque
from collections import Counter

def read():
	return int(input())

def readmap():
	return map(int, input().split())

def readlist():
	return list(map(int, input().split()))
(n, x, y) = readmap()
S = input()
A = [int(S[i]) for i in range(n)]
connected_0s = 0
is_0 = False
for i in range(n):
	if A[i] == 0:
		is_0 = True
		if i == n - 1:
			connected_0s += 1
	elif is_0:
		connected_0s += 1
		is_0 = False
if connected_0s == 0:
	print(0)
	quit()
if x < y:
	print(x * (connected_0s - 1) + y)
else:
	print(connected_0s * y)


(n, x, y) = map(int, input().split())
a = ['1'] + list(input())
c = 0
for i in range(n):
	if a[i:i + 2] == ['1', '0']:
		c += 1
print(max(c - 1, 0) * min(x, y) + (y if c >= 1 else 0))


(n, x, y) = map(int, input().split())
a = str(input())
f = 1
d = 0
if a.find('0') == -1:
	print(0)
else:
	for i in a:
		if i == '0' and f == 1:
			d += 1
			f = 0
		elif i == '1':
			f = 1
	print((d - 1) * min(x, y) + y)


(n, x, y) = map(int, input().strip().split())
count = 0
r = input()
if r[0] == '0':
	count = count + 1
for i in range(1, n):
	if r[i] == '0' and r[i - 1] != '0':
		count = count + 1
if count == 0:
	print(0)
	exit(0)
elif y < x:
	print(y * count)
else:
	print(x * (count - 1) + y)


def solve(s, cr, cn):
	count = 0
	for i in range(len(s)):
		if s[i] == '0' and (i == 0 or s[i - 1] == '1'):
			count += 1
	return (count - 1) * min(cr, cn) + cn if count > 0 else 0
(_, cr, cn) = map(int, input().split())
s = input()
print(solve(s, cr, cn))


(n, x, y) = list(map(int, input().split()))
a = input()
a = a + '1'
cnt = 0
for i in range(n):
	if a[i] == '0' and a[i + 1] == '1':
		cnt += 1
if cnt == 0:
	print(0)
	exit()
print(min(y * cnt, y + (cnt - 1) * x))


(n, x, y) = map(int, input().split())
A = input().strip()
B = [tmp for tmp in A.split('1') if len(tmp) > 0]
if len(B) == 0:
	print(0)
elif len(B) * y < (len(B) - 1) * x + y:
	print(len(B) * y)
else:
	print((len(B) - 1) * x + y)


(n, x, y) = map(int, input().split())
s = input()
c = len([_ for _ in s.split('1') if _])
ans = 1e+19
if not c:
	ans = 0
for i in range(c):
	ans = min(ans, i * x + (c - i) * y)
print(ans)


(n, x, y) = map(int, input().split())
a = str(input())
(c1, c0) = (0, 0)
i = 0
while i < n:
	if a[i] == '1':
		while i < n and a[i] == '1':
			i += 1
		c1 += 1
	else:
		while i < n and a[i] == '0':
			i += 1
		c0 += 1
if a[0] == '1':
	c1 -= 1
if a[n - 1] == '1':
	c1 -= 1
if c1 < 0:
	c1 = 0
out = min(c1 * x + y, c0 * y)
print(out)


(n, x, y) = list(map(int, input().split()))
s = ''
len_s = 0
a = input()
for i in range(n):
	if len_s == 0:
		s += a[i]
		len_s += 1
	elif a[i] != s[len_s - 1]:
		s += a[i]
		len_s += 1
sm = 0
if x < y:
	if len(s) > 3:
		sm += x * ((len(s) - 2) // 2)
elif len(s) > 3:
	sm += y * ((len(s) - 2) // 2)
sm += y
if len(s) != 1 and s[0] == '0' and (s[len(s) - 1] == '0'):
	if y < x:
		sm += y
	else:
		sm += x
if s == '1':
	sm = 0
print(sm)


(n, x, y) = map(int, input().split())
s = str(input())
l = list(s)
if l.count('1') == n:
	print(0)
else:
	if s[0] == '0':
		c = 1
	else:
		c = 0
	for i in range(1, n):
		if s[i] == '0' and s[i] != s[i - 1]:
			c += 1
	print((c - 1) * min(x, y) + y)


(n, x, y) = map(int, input().split())
cnt0 = len(list(filter(lambda a: a != '', input().split('1'))))
if cnt0 == 0:
	print(0)
else:
	print(min((cnt0 - 1) * x + y, cnt0 * y))


def f(reverse_cost, inverse_cost, bit_string):
	prev_value = True
	zero_section_count = 0
	for v in bit_string:
		cur_value = bool(v == '1')
		if prev_value != cur_value:
			if not cur_value:
				zero_section_count += 1
			prev_value = cur_value
	if zero_section_count:
		return min(reverse_cost, inverse_cost) * (zero_section_count - 1) + inverse_cost
	else:
		return 0
(n, x, y) = [int(i) for i in input().split()]
s = input()
print(f(x, y, s))


import sys
(bla, wort, *_) = sys.stdin.read().split('\n')
(n, x, y) = [int(z) for z in bla.split(' ')]
anz = wort[0] == '0'
for (a, b) in zip(wort[:-1], wort[1:]):
	if b == '0' and a != '0':
		anz += 1
if anz == 0:
	print(0)
else:
	print(y + min(x, y) * (anz - 1))


def readline():
	return map(int, input().split())

def main():
	(n, x, y) = readline()
	line = input()
	zero_segments = line.count('10') + line.startswith('0')
	print((zero_segments - 1) * min(x, y) + y if zero_segments else 0)
main()


(n, x, y) = [int(x) for x in input().split()]
s = input()
c = 0
for i in range(0, len(s) - 1):
	if s[i] == '0' and s[i + 1] == '1':
		c += 1
if s[len(s) - 1] == '0':
	c += 1
if c == 0:
	print(0)
else:
	print((c - 1) * min(x, y) + y)


import math as ma
from sys import exit
from decimal import Decimal as dec

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())
(n, x, y) = num()
s = input()
con = 0
for ch in range(1, n):
	if s[ch] != s[ch - 1] and s[ch - 1] == '0':
		con += 1
if s[n - 1] == '0':
	con += 1
if con == 0:
	print(0)
	exit()
ans = min(x, y) * (con - 1) + y
print(ans)


(n, x, y) = map(int, input().split())
s = input()
arr = [s[0]]
for i in range(len(s) - 1):
	if i == len(s) - 2:
		if s[i + 1] != s[i]:
			arr += [s[i + 1]]
	elif s[i + 1] != s[i]:
		arr += [s[i + 1]]
zc = 0
for j in range(len(arr)):
	if arr[j] == '0':
		zc += 1
fin1 = (zc - 1) * x + y
fin2 = zc * y
ans = min(fin1, fin2)
if s == '1' * len(s):
	ans = 0
print(ans)


import sys
import itertools
(n, x, y) = [int(i) for i in input().split()]
s = input()
s = s.strip('1')
if not s:
	print(0)
	sys.exit()
t = 0
for k in itertools.groupby(s):
	t += 1
t = t // 2 + 1
print(min((t - 1) * x + y, t * y))


def main():
	(n, x, y) = list(map(int, input().split()))
	a = input()
	islands = a[0] == '0'
	for i in range(1, n):
		if a[i] == '0':
			islands += a[i - 1] == '1'
	if islands == 0:
		print(0)
		return 0
	if x >= y:
		print(y * islands)
	else:
		print(x * (islands - 1) + y)
	return 0
main()


(N, x, y) = input().split()
x = int(x)
y = int(y)
array = input()
the_list = array.split('1')
length = len(the_list)
for k in the_list:
	if k == '':
		length -= 1
if length == 0:
	print(0)
elif x < y:
	print((length - 1) * x + y)
else:
	print(length * y)


(n, reverse, change) = map(int, input().split())
a = input()
g = list(filter(lambda x: x, a.split('1')))
nGroups = len(g)
print(0 if not nGroups else min((nGroups - 1) * reverse + change, nGroups * change))


import math

def solve(n, x, y, s):
	zero = 0
	for i in range(n):
		if s[i] == '0':
			zero += 1
	ans = math.inf
	segment = 0
	flag = False
	for i in range(n - 1):
		if s[i] != s[i + 1]:
			if s[i] == '0':
				if flag == False:
					segment += 1
					flag = True
				else:
					continue
			else:
				segment += 1
				flag = True
	cnt = 0
	for segment in range(segment, 0, -1):
		ans = min(ans, segment * y + cnt * x)
		cnt += 1
	if zero == n:
		print(y)
	elif ans == math.inf:
		print(0)
	else:
		print(ans)
(n, x, y) = map(int, input().split())
s = input()
solve(n, x, y, s)


def problem():
	in1 = input()
	in2 = input()
	inp1 = list(map(int, in1.split()))
	n = inp1[0]
	exc_cost = inp1[1]
	flip_cost = inp1[2]
	s = in2
	zeros = 0
	sign = s[0]
	for num in s[1:]:
		if num != sign:
			if sign == '0':
				zeros += 1
			sign = num
	if sign == '0':
		zeros += 1
	if zeros == 0:
		return 0
	if zeros == 1:
		return flip_cost
	cost1 = (zeros - 1) * exc_cost + flip_cost
	cost2 = zeros * flip_cost
	if cost1 <= cost2:
		return cost1
	else:
		return cost2
result = problem()
print(result)


(n, x, y) = input().split()
n = int(n)
x = int(x)
y = int(y)
s = input()
count = 0
is_zero = s[0] == '0'
if is_zero:
	count += 1
for i in range(1, n):
	if s[i] == '0' and (not is_zero):
		is_zero = True
		count += 1
	elif s[i] == '1' and is_zero:
		is_zero = False
if y <= x or count == 0:
	print(y * count)
else:
	print(x * (count - 1) + y)


(n, x, y) = map(int, input().split())
s = input()
sl = []
for i in s:
	sl += [int(i)]
sl.append(1)
count = 0
for i in range(n):
	if sl[i] == 0 and sl[i + 1] == 1:
		count += 1
if count != 0:
	print(y + min(x, y) * (count - 1))
else:
	print('0')


import sys
(n, x, y) = map(int, input().split())
s = input()
if s.count('1') == n:
	print(0)
	sys.exit()
if x > y:
	started = False
	sep = 0
	for c in s:
		if c == '0' and started:
			continue
		if c == '0' and (not started):
			sep += 1
			started = True
		if c == '1':
			started = False
	print(y * sep)
	sys.exit()
started = False
sep = 0
for c in s:
	if c == '0' and started:
		continue
	if c == '0' and (not started):
		sep += 1
		started = True
	if c == '1':
		started = False
print((sep - 1) * x + y)


(n, x, y) = map(int, input().split())
s = input().split('1')
a = []
for i in s:
	if i != '':
		a.append(i)
cnt = len(a)
ans = 10000000000000000000000000000000000000
flag = 0
for i in range(cnt):
	flag = 1
	p = i
	q = cnt - i
	val = p * x + q * y
	ans = min(ans, val)
if flag == 1:
	print(ans)
else:
	print(0)


(n, cx, cy) = [int(x) for x in input().split()]
s = input()
g0 = 0
for i in range(n):
	if s[i] == '0' and (i == 0 or s[i - 1] == '1'):
		g0 += 1
if g0 == 0:
	print('0')
else:

	def cost(x):
		return (g0 - x) * cy + cx * x
	best_x = None
	for x in range(g0):
		if best_x is None or cost(x) < cost(best_x):
			best_x = x
	best_y = g0 - best_x
	print(best_x * cx + best_y * cy)


(n, x, y) = map(int, input().split())
a = input()
k = 0
i = 0
if a[i] == '0':
	k += 1
	while i < n and a[i] == '0':
		i += 1
for j in range(i, n - 1):
	if a[j] == '1' and a[j + 1] == '0':
		k += 1
if k == 0:
	print(0)
elif x < y:
	print((k - 1) * x + y)
else:
	print(k * y)


R = lambda : list(map(int, input().split()))
(n, x, y) = R()
l = input()
if x < y:
	k = 0
	for i in range(0, n - 1):
		if l[i] == '0' and l[i + 1] == '1':
			k += 1
	if k == 0 and l[n - 1] == '1':
		y = 0
	elif l[n - 1] == '1' and k > 0:
		k -= 1
	print(k * x + y)
else:
	k = 0
	for i in range(n - 1):
		if l[i] == '0' and l[i + 1] == '1':
			k += 1
	if l[n - 1] == '0':
		k += 1
	print(y * k)


def solve(s, x, y):
	z = False
	c = 0
	for i in range(len(s)):
		if s[i] == '0' and (not z):
			z = True
			c += 1
		elif s[i] != '0' and z:
			z = False
	min_cost = float('inf')
	for i in range(c):
		min_cost = min(min_cost, i * x + (c - i) * y)
	return 0 if min_cost == float('inf') else min_cost
(_, x, y) = [int(x) for x in input().strip().split(' ')]
s = input()
print(solve(s, x, y))


def countIt(a):
	assert a
	count = 1
	start = ord(a[0]) - ord('0')
	delim = 1 - start
	for ch in a:
		if ord(ch) - ord('0') == delim:
			count += 1
			delim = 1 - delim
	return (count, start)

def calcIt(f_count, start, x, y):
	if f_count == 1:
		return y if start == 0 else 0
	if f_count == 2:
		return y
	cost = 0
	if x < y:
		if f_count > 3:
			cost = x * (f_count // 2 - 1)
			f_count = 2 + f_count % 2
		if f_count == 3:
			if start == 0:
				cost += x
		return cost + y
	else:
		if f_count > 3:
			cost = y * (f_count // 2 - 1)
			f_count = 2 + f_count % 2
		if f_count == 3:
			return cost + y if start == 1 else cost + 2 * y
		if f_count == 2:
			return cost + y
		return cost + y if start == 0 else cost

def calc(a, x, y):
	(f_count, start) = countIt(a)
	return calcIt(f_count, start, x, y)

def get_ints():
	return [int(n) for n in input().split()]

def get_floats():
	return [float(n) for n in input().split()]
a = get_ints()
assert len(a) == 3
(n, x, y) = (a[0], a[1], a[2])
a = input()
res = calc(a, x, y)
print(res)


n = input().split(' ')
s = input()
x = int(n[1])
y = int(n[2])
com = ''
nn = 0
for i in s:
	if len(com) == 0 or com[-1] != i:
		com += i
		if i == '0':
			nn += 1
if nn != 0:
	print(min(nn * y, (nn - 1) * x + y))
else:
	print(0)


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
sys.setrecursionlimit(10000)

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

@mt
def slv(N, X, Y, A):
	n = len(list(filter(lambda x: len(x) > 0, A.split('1'))))
	if n == 0:
		return 0
	if Y > X:
		return Y + (n - 1) * X
	return n * Y

def main():
	(N, X, Y) = read_int_n()
	A = read_str()
	print(slv(N, X, Y, A))
main()


(n, x, y) = map(int, input().split())
l = list(input())
if l.count('1') == n:
	print(0)
	exit()
cnt = 0
cnt0 = 0
from itertools import groupby
for (k, g) in groupby(l):
	cnt += 1
	cnt0 += k == '0'
print(min(x, y) * (cnt0 - 1) + y)


(n, x, y) = input().split()
n = int(n)
x = int(x)
y = int(y)
s = input()
s += '@'
zero = 0
one = 0
for i in range(n):
	if s[i] == '1' and (s[i + 1] == '0' or s[i + 1] == '@'):
		one += 1
	if s[i] == '0' and (s[i + 1] == '1' or s[i + 1] == '@'):
		zero += 1
if zero == 0:
	print(0)
else:
	print((zero - 1) * min(x, y) + y)


(n, x, y) = list(map(int, input().split()))
a = '1' + input()
m = sum((1 for i in range(1, n + 1) if a[i - 1] == '1' and a[i] == '0'))
ans = min((x * i + y * (m - i) for i in range(m)), default=0)
print(ans)


(n, x, y) = map(int, input().split())
a = str(input())
(cnt, k) = (0, 0)
for i in range(n):
	if a[i] == '0':
		cnt += 1
	else:
		if cnt > 0:
			k += 1
		cnt = 0
if cnt > 0:
	k += 1
if k == 0:
	print(0)
else:
	print((k - 1) * min(x, y) + y)


(n, x, y) = map(int, input().split())
s = input()
data = s.split('1')
c = 0
for i in data:
	if len(i) != 0:
		c += 1
if c == 0:
	print(0)
else:
	print((c - 1) * min(x, y) + y)


from math import *
import sys
input = sys.stdin.readline

def main():
	(n, x, y) = [int(x) for x in input().split(' ')]
	s = input().strip()
	cnt = 0
	i = 0
	while i < len(s):
		good = False
		while i < len(s) and s[i] == '0':
			i += 1
			good = True
		cnt += good
		while i < len(s) and s[i] == '1':
			i += 1
	best = 0 if cnt == 0 else 1e+20
	for i in range(1, cnt + 1):
		best = min(best, (cnt - i) * x + i * y)
	print(best)
main()


import re

def repl(x):
	return x.group()[0]
(n, x, y) = [int(z) for z in input().split()]
s = input().strip()
s = re.sub('(?P<digit>\\d)(?P=digit)+', repl, s)
zeros = s.count('0')
if zeros == 0:
	ans = 0
else:
	ans = min([x * i + y * (zeros - i) for i in range(0, zeros)])
print(ans)


def count_components(line):
	in_zero_component = False
	num_components = 0
	for c in line:
		if c == '0':
			if not in_zero_component:
				num_components += 1
			in_zero_component = True
		else:
			in_zero_component = False
	return num_components
(_, reverse_cost, invert_cost) = [int(x) for x in input().split()]
line = input()
num_components = count_components(line)
cost = (num_components - 1) * min(reverse_cost, invert_cost) + invert_cost if num_components > 0 else 0
print(cost)


(n, x, y) = map(int, input().split())
s = input()
a = [0] * int(300000.0 + 5)
b = [0] * int(300000.0 + 5)
for i in range(n):
	a[i + 1] = ord(s[i]) - ord('0')
a[0] = -1
cnt = 0
for i in range(1, n + 1):
	if a[i] != a[i - 1]:
		cnt += 1
		b[cnt] = a[i]
ct = 0
for i in range(1, cnt + 1):
	if b[i] == 0:
		ct += 1
if ct == 0:
	print(0)
	exit()
if x >= y:
	print(ct * y)
else:
	print(y + x * (ct - 1))


(n, x, y) = input().strip().split()
(n, x, y) = (int(n), int(x), int(y))
s = input().strip()
if n == 1 and s == '0':
	print(y)
elif n == 1 and s == '1':
	print(0)
else:
	l = [s[0]]
	for i in s[1:]:
		if i != l[-1]:
			l.append(i)
	t = l.count('0')
	if t == 0:
		print(0)
	else:
		print(min((t - 1) * x + y, t * y))


(n, x, y) = map(int, input().split())
s = list(map(int, list(input())))
if s[0] == 0:
	se = 1
else:
	se = 0
r = s[0]
for i in range(1, n):
	if s[i] == int(not r) and r == 1:
		se += 1
		r = 0
	elif s[i] == int(not r):
		r = 1
k = se * y
for i in range(1, se):
	k = min(k, (se - i) * y + i * x)
print(k)


from math import *
(n, x, y) = map(int, input().split())
s = str(input())
arr = []
k = 0
for i in s:
	if i == '0':
		k += 1
	else:
		if k == 0:
			pass
		else:
			arr.append(k)
		k = 0
if k != 0:
	arr.append(k)
if y <= x:
	print(len(arr) * y)
else:
	z = x - y
	j = 1
	ans = y * len(arr)
	while j < len(arr):
		ans = min(ans, y * len(arr) + z * j)
		j += 1
	print(ans)


import sys
import math
from functools import reduce
import bisect

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def input():
	return sys.stdin.readline().rstrip()

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return -1
(n, x, y) = getNM()
s = input()
seg = 0
t = 1
for i in range(n):
	if s[i] == '0':
		if t:
			seg += 1
		t = 0
	else:
		t = 1
if y <= x:
	print(seg * y)
elif seg == 0:
	print(0)
else:
	print((seg - 1) * x + y)


(n, x, y) = [int(i) for i in input().split()]
v = 1
s = list(input())
cnt = 0
for digit in s:
	if digit == '0' and v == 1:
		cnt += 1
		v = 0
	if digit == '1':
		v = 1
if cnt == 0:
	print(0)
	exit(0)
ans = min(cnt * y, (cnt - 1) * x + y)
print(ans)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, X, Y) = getInts()
	S = listStr()
	a = 0
	flag = False
	for s in S:
		if s == '0':
			flag = True
		else:
			if flag:
				a += 1
			flag = False
	if flag:
		a += 1
	if not a:
		return 0
	return min((a - 1) * X + Y, a * Y)
print(solve())