There are two 100-story buildings, called A and B. (In this problem, the ground floor is called the first floor.)
For each i = 1,\dots, 100, the i-th floor of A and that of B are connected by a corridor.
Also, for each i = 1,\dots, 99, there is a corridor that connects the (i+1)-th floor of A and the i-th floor of B.
You can traverse each of those corridors in both directions, and it takes you x minutes to get to the other end.
Additionally, both of the buildings have staircases. For each i = 1,\dots, 99, a staircase connects the i-th and (i+1)-th floors of a building, and you need y minutes to get to an adjacent floor by taking the stairs.
Find the minimum time needed to reach the b-th floor of B from the a-th floor of A.

-----Constraints-----
 - 1 \leq a,b,x,y \leq 100
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
a b x y

-----Output-----
Print the minimum time needed to reach the b-th floor of B from the a-th floor of A.

-----Sample Input-----
2 1 1 5

-----Sample Output-----
1

There is a corridor that directly connects the 2-nd floor of A and the 1-st floor of B, so you can travel between them in 1 minute.
This is the fastest way to get there, since taking the stairs just once costs you 5 minutes.

Source: atcoder | Difficulty: MEDIUM_HARD


Solutions:
(a, b, x, y) = map(int, input().split())
y = min(y, 2 * x)
if a == b or a == b + 1:
	print(x)
	return
ans = x + abs(a - b) * y
if a > b:
	ans -= y
print(ans)


import heapq
(a, b, x, y) = map(int, input().split())
G = {}
for i in range(1, 101):
	G[0, i] = []
	if i - 1 >= 1:
		G[0, i].append((0, i - 1, y))
		G[0, i].append((1, i - 1, x))
	if i + 1 <= 100:
		G[0, i].append((0, i + 1, y))
	G[0, i].append((1, i, x))
	G[1, i] = []
	if i - 1 >= 1:
		G[1, i].append((1, i - 1, y))
	if i + 1 <= 100:
		G[1, i].append((1, i + 1, y))
		G[1, i].append((0, i + 1, x))
	G[1, i].append((0, i, x))
dist = {}
INFTY = 30000
for i in range(1, 101):
	dist[0, i] = INFTY
	dist[1, i] = INFTY
hist = {}
for i in range(1, 101):
	hist[0, i] = 0
	hist[1, i] = 0
heap = [(0, (0, a))]
dist[0, a] = 0
hist[0, a] = 1
while heap:
	(d, x) = heapq.heappop(heap)
	if dist[x] < d:
		continue
	hist[x] = 1
	for (i, j, dy) in G[x]:
		y = (i, j)
		if hist[y] == 0 and dist[y] > d + dy:
			dist[y] = d + dy
			heapq.heappush(heap, (d + dy, y))
print(dist[1, b])


(a, b, x, y) = list(map(int, input().split()))
print(abs((b - a) * 2 + 1) // 2 * min(x * 2, y) + x)


(a, b, x, y) = list(map(int, input().split()))
diff = a - b
if diff == 0:
	print(x)
elif diff > 0:
	print(min(x + (abs(diff) - 1) * y, (abs(diff) * 2 - 1) * x))
else:
	print(min(x + abs(diff) * y, (abs(diff) * 2 + 1) * x))


import heapq
(a, b, x, y) = list(map(int, input().split()))
dist = [10 ** 30 for i in range(200)]
G = [[] for i in range(200)]
a -= 1
b -= 1
b += 100
for i in range(99):
	G[i].append((i + 1, y))
	G[i + 1].append((i, y))
	G[i + 100].append((i + 1 + 100, y))
	G[i + 1 + 100].append((i + 100, y))
for i in range(100):
	G[i].append((i + 100, x))
	G[i + 100].append((i, x))
for i in range(99):
	G[i + 1].append((i + 100, x))
	G[i + 100].append((i + 1, x))
dist[a] = 0
q = []
heapq.heappush(q, (0, a))
while q:
	(d, r) = heapq.heappop(q)
	if dist[r] < d:
		continue
	for (p, cost) in G[r]:
		if dist[p] > dist[r] + cost:
			dist[p] = dist[r] + cost
			heapq.heappush(q, (dist[p], p))
print(dist[b])


(a, b, x, y) = map(int, input().split())
(a, b) = (a - 1, b - 1)
g = [[] for _ in range(200)]
for i in range(100):
	g[i].append((x, 100 + i))
	g[100 + i].append((x, i))
for i in range(99):
	g[i + 1].append((x, 100 + i))
	g[100 + i].append((x, i + 1))
for i in range(99):
	g[i].append((y, i + 1))
	g[i + 1].append((y, i))
for i in range(99):
	g[i + 100].append((y, i + 1 + 100))
	g[i + 1 + 100].append((y, i + 100))
import heapq
INF = 10 ** 18

def dijkstra_heap(s, edge):
	n = len(edge)
	d = [INF] * n
	used = [True] * n
	d[s] = 0
	used[s] = False
	edgelist = []
	for e in edge[s]:
		heapq.heappush(edgelist, e)
	while len(edgelist):
		minedge = heapq.heappop(edgelist)
		if not used[minedge[1]]:
			continue
		v = minedge[1]
		d[v] = minedge[0]
		used[v] = False
		for e in edge[v]:
			if used[e[1]]:
				heapq.heappush(edgelist, (e[0] + d[v], e[1]))
	return d
d = dijkstra_heap(a, g)
print(d[b + 100])


import math
(a, b, x, y) = list(map(int, input().split()))
w = abs(2 * b + 1 - 2 * a)
print(math.floor(w / 2) * min(2 * x, y) + x)


(a, b, x, y) = map(int, input().split())
d = abs(2 * b + 1 - 2 * a)
Yd = min([2 * x, y])
print(d // 2 * Yd + x)


(a, b, x, y) = map(int, input().split())
dif = a - b
elv = min(2 * x, y)
if dif > 0:
	ans = (dif - 1) * elv + x
else:
	ans = -dif * elv + x
print(ans)


(a, b, x, y) = map(int, input().split())
y = min(y, 2 * x)
if a == b:
	print(x)
elif a > b:
	print(y * (a - b - 1) + x)
elif a < b:
	print(y * (b - a) + x)


from sys import stdin
pin = stdin.readline
from heapq import heapify, heappop, heappush
INF = 1000000000000000000
V = 0
G = [[] for _ in [0] * 100000]
d = [INF] * 100000

def dijkstra(s):
	que = []
	heapify(que)
	d[s] = 0
	heappush(que, [0, s])
	while que:
		p = heappop(que)
		v = p[1]
		if d[v] < p[0]:
			continue
		for i in range(len(G[v])):
			e = G[v][i]
			if d[e[0]] > d[v] + e[1]:
				d[e[0]] = d[v] + e[1]
				heappush(que, [d[e[0]], e[0]])
	return

def main():
	(a, b, x, y) = map(int, pin().split())
	V = 200
	a -= 1
	b -= 1
	for i in range(100):
		G[i].append([i + 100, x])
		G[i + 100].append([i, x])
	for i in range(99):
		G[i + 1].append([i + 100, x])
		G[i + 100].append([i + 1, x])
	for i in range(99):
		G[i + 1].append([i, y])
		G[i].append([i + 1, y])
		G[i + 101].append([i + 100, y])
		G[i + 100].append([i + 101, y])
	dijkstra(a)
	print(d[b + 100])
	return
main()


(a, b, x_yoko, y_tate) = list(map(int, input().split()))
if a == b:
	ans = x_yoko
elif a > b:
	up = (a - b) * 2 * x_yoko - x_yoko
	cross = (a - b - 1) * y_tate + x_yoko
	ans = min(up, cross)
else:
	up = (b - a) * y_tate + x_yoko
	cross = (b - a) * 2 * x_yoko + x_yoko
	ans = min(up, cross)
print(ans)


def LI():
	return list(map(int, input().split()))
(a, b, x, y) = LI()
ans = abs(a - b) * y + x
if a > b:
	ans -= y
if a == b or a == b + 1:
	rouka = x
elif a < b:
	rouka = x
	rouka += (b - a) * x * 2
else:
	a -= 1
	rouka = x
	rouka += (a - b) * x * 2
ans = min(ans, rouka)
print(ans)


from sys import stdin, setrecursionlimit
import bisect, collections, copy, heapq, itertools, math, string
setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 1000000007

def input():
	return stdin.readline().strip()

def main():
	(a, b, x, y) = list(map(int, input().split()))
	ans = abs(2 * b + 1 - 2 * a) // 2 * min(2 * x, y) + x
	print(ans)
	return

def __starting_point():
	main()
__starting_point()


(a, b, x, y) = map(int, input().split())
if b - a > 0:
	d = b - a
	print(min(x + d * y, d * 2 * x + x))
elif b - a < 0:
	d = a - b
	print(min((d - 1) * y + x, d * 2 * x - x))
else:
	print(x)


s = list(map(int, input().split()))
a = s[0]
b = s[1]
x = s[2]
y = s[3]
if a == b:
	print(x)
elif a < b:
	print(min(x + (b - a) * y, ((b - a) * 2 + 1) * x))
else:
	print(min(((a - b) * 2 - 1) * x, x + (a - b - 1) * y))


(a, b, x, y) = list(map(int, input().split()))
if a == b:
	print(x)
elif a < b:
	ans = min(y, 2 * x) * (b - a) + x
	print(ans)
else:
	ans = min(y, 2 * x) * (a - b - 1) + x
	print(ans)


(a, b, x, y) = list(map(int, input().split()))
if a == b:
	print(x)
	return
ans = 10 ** 10
dif = abs(a - b)
for step in range(dif + 1):
	if a < b:
		hollway = 2 * (dif - step) + 1
	else:
		hollway = max(2 * (dif - step) - 1, 0)
	ans = min(ans, x * hollway + y * step)
print(ans)


def resolve():
	(a, b, x, y) = map(int, input().split())
	if b >= a:
		print((b - a) * min(2 * x, y) + x)
	else:
		print((a - b - 1) * min(2 * x, y) + x)
resolve()


import collections
import heapq

class Dijkstra:

	def __init__(self):
		self.e = collections.defaultdict(list)

	def add(self, u, v, d):
		self.e[u].append([v, d])
		self.e[v].append([u, d])

	def delete(self, u, v):
		self.e[u] = [_ for _ in self.e[u] if _[0] != v]
		self.e[v] = [_ for _ in self.e[v] if _[0] != u]

	def search(self, s):
		d = collections.defaultdict(lambda : float('inf'))
		d[s] = 0
		q = []
		heapq.heappush(q, (0, s))
		v = collections.defaultdict(bool)
		while len(q):
			(k, u) = heapq.heappop(q)
			if v[u]:
				continue
			v[u] = True
			for (uv, ud) in self.e[u]:
				if v[uv]:
					continue
				vd = k + ud
				if d[uv] > vd:
					d[uv] = vd
					heapq.heappush(q, (vd, uv))
		return d
(A, B, X, Y) = map(int, input().split())
graph = Dijkstra()
for i in range(1, 101):
	graph.add(i, 100 + i, X)
for i in range(1, 100):
	graph.add(i + 1, 100 + i, X)
for i in range(1, 100):
	graph.add(i, i + 1, Y)
	graph.add(100 + i, 100 + i + 1, Y)
SA = graph.search(A)
print(SA[B + 100])


(a, b, x, y) = list(map(int, input().split()))
ida = a * 2
idb = b * 2 + 1
diff = abs(ida - idb)
ans = 0
if 2 * x <= y:
	ans = diff * x
else:
	ans = x + diff // 2 * y
print(ans)


(a, b, x, y) = list(map(int, input().split()))
if a == b:
	print(x)
if a < b:
	dif = b - a
	print(min(dif * y + x, dif * 2 * x + x))
if a > b:
	dif = a - b
	print(min((2 * dif - 1) * x, (dif - 1) * y + x))


import math
(a, b, x, y) = map(int, input().split())
t = min(2 * x, y)
d = abs(2 * b + 1 - 2 * a)
print(math.floor(d / 2) * t + x)


ma = lambda : map(int, input().split())
lma = lambda : list(map(int, input().split()))
tma = lambda : tuple(map(int, input().split()))
ni = lambda : int(input())
yn = lambda fl: print('Yes') if fl else print('No')
ips = lambda : input().split()
import collections
import math
import itertools
import heapq as hq
import sys
ceil = math.ceil
gcd = math.gcd
RL = sys.stdin.readline
INF = 10 ** 15

def ceilab(a, b):
	return (a + b - 1) // b
(a, b, x, y) = ma()
if y > 2 * x:
	y = 2 * x
if a == b:
	print(x)
elif a > b:
	print((a - b - 1) * y + x)
else:
	print((b - a) * y + x)


(a, b, x, y) = map(int, input().split())
if a == b:
	print(x)
elif a < b:
	ans1 = (b - a) * y + x
	ans2 = (b - a) * x * 2 + x
	print(min(ans1, ans2))
else:
	ans1 = (a - b - 1) * y + x
	ans2 = (a - b - 1) * x * 2 + x
	print(min(ans1, ans2))


(a, b, x, y) = list(map(int, input().split()))
num = a - b
if num == 0:
	print(x)
elif num < 0:
	num = abs(num)
	ans = x
	if num * y > num * (x * 2):
		print(ans + num * (x * 2))
	else:
		print(ans + num * y)
else:
	num -= 1
	ans = x
	if num == 0:
		print(ans)
	elif num * y > num * (x * 2):
		print(ans + num * (x * 2))
	else:
		print(ans + num * y)


(a, b, x, y) = list(map(int, input().split()))
if a == b:
	ans = x
else:
	dif = abs(a - b)
	if a < b:
		ans = x + min(2 * x, y) * dif
	else:
		ans = x + min(2 * x, y) * (dif - 1)
print(ans)


(a, b, x, y) = list(map(int, input().split()))
z = min(2 * x, y)
if a <= b:
	print(x + z * (b - a))
else:
	print(x + z * (a - b - 1))


(a, b, x, y) = [int(hoge) for hoge in input().split()]
stair = min(y, 2 * x)
isle = x
ans = 0
if a > b:
	ans = (a - b - 1) * stair + isle
else:
	ans = (b - a) * stair + isle
print(ans)


(a, b, x, y) = map(int, input().split())
ans = 0
if a == b:
	ans = x
if a > b:
	ans = min(x + (a - b - 1) * y, x * (2 * a - 2 * b - 1))
if a < b:
	ans = min(x + y * (b - a), x * (2 * b - 2 * a + 1))
print(ans)


(a, b, x, y) = map(int, input().split())
if a > b:
	tmp = x + (a - b - 1) * y
	tmp2 = (a - b) * x + (a - b - 1) * x
	print(min(tmp, tmp2))
elif a == b:
	print(x)
else:
	tmp = x + (b - a) * y
	tmp2 = (b - a) * x + (b - a + 1) * x
	print(min(tmp, tmp2))


(a, b, x, y) = map(int, input().split())
(a, b) = (a - 1, b - 1)
m = up = min(2 * x, y)
if a <= b:
	print(x + m * (b - a))
else:
	print(x + m * (a - b - 1))


def solve(a, b, x, y):
	if b < a:
		return x + (a - b - 1) * min(2 * x, y)
	else:
		return x + (b - a) * min(2 * x, y)
(a, b, x, y) = list(map(int, input().split()))
print(solve(a, b, x, y))


def __starting_point():
	(a, b, x, y) = list(map(int, input().split()))
	ans = 0
	ud_sbn = abs(a - b)
	up = False
	if a - b < 0:
		up = True
	if ud_sbn == 0:
		ans = x
	elif up:
		u1 = ((ud_sbn + 1) * 2 - 1) * x
		u2 = x + ud_sbn * y
		ans = min(u1, u2)
	else:
		d1 = (ud_sbn * 2 - 1) * x
		d2 = x + (ud_sbn - 1) * y
		ans = min(d1, d2)
	print(ans)
__starting_point()


from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline

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

def warizan(a, b):
	return (a // b, a % b)

def combinations_count(n, r):
	r = min(r, n - r)
	numer = reduce(mul, list(range(n, n - r, -1)), 1)
	denom = reduce(mul, list(range(1, r + 1)), 1)
	return numer // denom
mod = 1000000007

def combinations_count_mod(n, r):
	r = min(r, n - r)
	numer = reduce(lambda x, y: x * y % mod, list(range(n, n - r, -1)), 1)
	denom = pow(reduce(lambda x, y: x * y % mod, list(range(1, r + 1)), 1), mod - 2, mod)
	return numer * denom % mod
(a, b, x, y) = list(map(int, input().strip().split()))
h = abs(a - b)
if a < b:
	temp1 = y * h + x
	temp2 = 2 * x * h + x
	eprint('temp1,temp2 ', end=':\n')
	eprint(temp1, temp2)
	print(min(temp1, temp2))
elif a == b:
	print(x)
else:
	temp1 = (h - 1) * y + x
	temp2 = 2 * x * (h - 1) + x
	eprint('temp1,temp2 ', end=':\n')
	eprint(temp1, temp2)
	print(min(temp1, temp2))


import math
import copy
import bisect
from itertools import accumulate
from collections import Counter, defaultdict, deque

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

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

def ceil(U, V):
	return (U + V - 1) // V

def modf1(N, MOD):
	return (N - 1) % MOD + 1
(a, b, x, y) = mp()
u = x * 2
if a == b:
	print(x)
elif a > b:
	sa = a - b - 1
	print(min(sa * u + x, sa * y + x))
else:
	sa = b - a
	print(min(x + sa * y, sa * u + x))


from collections import defaultdict
from sys import stdin
input = stdin.readline

def solve():
	(a, b, x, y) = map(int, input().split())
	d = abs(a - b)
	if d == 0:
		print(x)
		return
	elif a < b:
		print(d * y + x if y <= 2 * x else d * 2 * x + x)
		return
	else:
		print((d - 1) * y + x if y <= 2 * x else d * x * 2 - x)

def __starting_point():
	solve()
__starting_point()


(a, b, x, y) = [int(i) for i in input().split()]
if a == b:
	print(x)
elif a < b:
	if 2 * x > y:
		print((b - a) * y + x)
	else:
		print(2 * (b - a) * x + x)
elif 2 * x > y:
	print((a - b - 1) * y + x)
else:
	print(2 * (a - b) * x - x)


import sys

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

def mapint():
	return map(int, input().split())
sys.setrecursionlimit(10 ** 9)
(a, b, x, y) = mapint()
if a > b:
	n = a - b
	print(min((n - 1) * y + x, x * 2 * n - x))
else:
	n = b - a
	print(min(n * y + x, x * 2 * n + x))


import sys
from functools import reduce
zz = 1
sys.setrecursionlimit(10 ** 5)
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def ii():
	return input().rstrip()

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def gtc(tc, ans):
	print(('Case #' + str(tc) + ':', ans))

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def isvalid(i, j, n, m):
	return 0 <= i < n and 0 <= j < m

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
uu = t
while t > 0:
	t -= 1
	(a, b, x, y) = mi()
	y = min(y, 2 * x)
	if a > b:
		print((a - b - 1) * y + x)
	else:
		print((b - a) * y + x)


s = list(map(int, input().split()))
a = int(s[0])
b = int(s[1])
x = int(s[2])
y = int(s[3])
move_withoutstep_1 = 9999999999
move_withoutstep_2 = 9999999999
if a > b:
	move_withoutstep_1 = (a - b - 1) * x + (a - b) * x
elif a <= b:
	move_withoutstep_2 = (b - a + 1) * x + (b - a) * x
move_upstairs = 9999999999
move_downstairs = 9999999999
if a < b:
	move_upstairs = (b - a) * y + x
elif a > b:
	move_downstairs = (a - b - 1) * y + x
print(min(move_withoutstep_1, move_withoutstep_2, move_upstairs, move_downstairs))


(a, b, x, y) = map(int, input().split())
ans = 0
if a > b:
	if 2 * x > y:
		ans = (a - b - 1) * y + x
	else:
		ans = (a - b) * x * 2 - x
elif 2 * x > y:
	ans = (b - a) * y + x
else:
	ans = (b - a) * x * 2 + x
print(ans)


(a, b, x, y) = map(int, input().split())
g = [[10 ** 8 for _ in range(200)] for i in range(200)]
for i in range(200):
	g[i][i] = 0
for i in range(100):
	g[i][i + 100] = x
	g[i + 100][i] = x
for i in range(99):
	g[i + 1][i + 100] = x
	g[i + 100][i + 1] = x
for i in range(99):
	g[i + 1][i] = y
	g[i][i + 1] = y
for i in range(99):
	g[i + 101][i + 100] = y
	g[i + 100][i + 101] = y

def warchall_floyd(n):
	for i in range(n):
		for j in range(n):
			for k in range(n):
				g[j][k] = min(g[j][k], g[j][i] + g[i][k])
warchall_floyd(200)
print(g[a - 1][100 + b - 1])


(a, b, x, y) = map(int, input().split())
if b > a:
	route_x = x + 2 * x * (b - a)
	route_y = x + y * (b - a)
elif a == b:
	route_x = x
	route_y = x + y
else:
	route_x = x + 2 * x * (a - b - 1)
	route_y = x + y * (a - b - 1)
answer = min(route_x, route_y)
print(answer)


(a, b, c, d) = map(int, input().split())
if a == b:
	print(c)
	return
if a < b:
	print(min(c + d * (b - a), c + 2 * c * (b - a)))
else:
	print(min(c + d * (a - b - 1), c + 2 * c * (a - b - 1)))


(a, b, x, y) = list(map(int, input().split()))
if a == b:
	print(x)
else:
	res = 100000000000000000
	if a != 1:
		aa = a - 1
		tmp = x
		tmp += y * (aa - b)
		res = min(res, tmp)
	tmp = x
	tmp += y * abs(a - b)
	res = min(res, tmp)
	if a == b:
		res = min(x, res)
	elif a > b:
		res = min(res, x * (abs(a - b) * 2 - 1))
	elif a < b:
		res = min(res, x * (abs(a - b) * 2 + 1))
	print(res)


(a, b, x, y) = map(int, input().split())
v = min(y, 2 * x)
if a == b:
	print(x)
	return
v = min(2 * x, y)
if a > b:
	ans = v * (a - b - 1) + x
else:
	ans = v * (b - a) + x
print(ans)


(a, b, x, y) = list(map(int, input().split()))
if a == b:
	print(x)
	return
if a > b:
	h = a - b
	if y * (h - 1) >= 2 * x * (h - 1):
		print(2 * x * (h - 1) + x)
		return
	else:
		print(y * (h - 1) + x)
		return
else:
	h = b - a
	if y >= 2 * x:
		print(2 * x * h + x)
		return
	else:
		print(y * h + x)
		return


import math
from functools import reduce

def readGenerator():
	while True:
		tokens = input().split(' ')
		for t in tokens:
			yield t
reader = readGenerator()

def readWord():
	return next(reader)

def readInt():
	return int(next(reader))

def readFloat():
	return float(next(reader))

def readLine():
	return input()

def fib(n, f1, f2, i):
	if n <= f1:
		return i
	return fib(n, f2, f1 + f2, i + 1)

def bin(a, num):
	left = 0
	right = len(a) - 1
	while right - left > 1:
		mid = (right + left) // 2
		if a[mid] < num:
			left = mid
		else:
			right = mid
	return a[left] == num or a[right] == num

def lcm(x, y):
	tmp = x
	while tmp % y != 0:
		tmp += x
	return tmp

def createGraph(x, y):
	g = []
	for i in range(200):
		g.append([])
	for i in range(100):
		g[i].append((i + 100, y))
		g[i + 100].append((i, y))
		if i > 0:
			g[i].append((i - 1, x))
			g[100 + i].append((i + 99, x))
			g[i].append((i + 99, y))
			g[99 + i].append((i, y))
		if i < 99:
			g[i].append((i + 1, x))
			g[100 + i].append((i + 101, x))
	return g

def solve(a, b, y, x):
	g = createGraph(x, y)
	d = [10 ** 10] * 200
	d[a] = 0
	v = [False] * 200
	for _ in range(200):
		vi = -1
		mn = 10 ** 10
		for j in range(200):
			if d[j] < mn and (not v[j]):
				vi = j
				mn = d[j]
		for (dest, t) in g[vi]:
			d[dest] = min(d[dest], d[vi] + t)
		v[vi] = True
	return d[b]
(a, b, x, y) = [readInt() for _ in range(4)]
print(solve(a - 1, b + 99, x, y))


import sys
import math
import re
import random
import itertools
import bisect
from copy import copy
from collections import deque, Counter, defaultdict
from decimal import Decimal

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 9
(a, b, x, y) = map(int, input().split())
num = abs(a - b)
if a > b:
	print(min(x * (num * 2 - 1), x + y * (num - 1)))
elif a == b:
	print(x)
else:
	print(min(x * (num * 2 + 1), x + y * num))


import sys
(a, b, x, y) = map(int, input().split())
ans = 0
if a == b:
	ans = x
elif a < b:
	move1 = (b - a) * x * 2 + x
	move2 = (b - a) * y + x
	ans = min(move1, move2)
else:
	move1 = (a - b) * x * 2 - x
	move2 = (a - b) * y + x
	ans = min(move1, move2)
	move3 = (a - b - 1) * y + x
	ans = min(ans, move3)
print(ans)


(a, b, x, y) = map(int, input().split())
hoge = max(b - a, a - b - 1)
print(min(hoge * x * 2, hoge * y) + x)


import math
import numpy as np
import sys
input = sys.stdin.readline

def main():
	(a, b, x, y) = list(map(int, input().split()))
	if b > a:
		d = b - a
		t1 = y * d + x
		t2 = 2 * x * d + x
		print(min(t1, t2))
	elif a == b:
		print(x)
	else:
		d = a - b
		t1 = y * (d - 1) + x
		t2 = 2 * x * (d - 1) + x
		print(min(t1, t2))
main()


(a, b, x, y) = list(map(int, input().split()))
if b < a:
	d1 = abs(b + 1 - a) * y + x
	d2 = (abs(b - a) * 2 - 1) * x
else:
	d1 = abs(b - a) * y + x
	d2 = (abs(b - a) * 2 + 1) * x
print(min(d1, d2))


(a, b, x, y) = map(int, input().split())
vertical = min(2 * x, y)
d = abs(a - b)
if a > b:
	ans = (d - 1) * vertical + x
else:
	ans = d * vertical + x
print(ans)


(A, B, X, Y) = map(int, input().split())
x = A * 2
y = B * 2 + 1
l = abs(y - x)
o = X
t = min(X * 2, Y)
ans = l // 2 * t + l % 2 * o
print(ans)


(a, b, x, y) = map(int, input().split())
t = 0
if a > b:
	c = a - 1 - b
else:
	c = b - a
t += x
if x * 2 < y:
	t += c * x * 2
else:
	t += c * y
print(t)


(a, b, x, y) = map(int, input().split())
ans = 0
if a > b:
	a1 = x + y * (a - b - 1)
	a2 = x * (2 * (a - b) - 1)
else:
	a1 = x + y * (b - a)
	a2 = x * (2 * (b - a) + 1)
ans = min(a1, a2)
print(ans)


n = 100
(a, b, x, y) = list(map(int, input().split()))
dpa = [-1] * (n + 1)
dpb = [-1] * (n + 1)
dpa[a] = 0
dpb[a] = x
for ii in range(a, n):
	dpb[ii] = dpa[ii] + x
	dpa[ii + 1] = min(dpa[ii] + y, dpb[ii] + x)
dpb[n] = min(dpa[n] + x, dpb[n - 1] + y)
for ii in range(a, 1, -1):
	dpb[ii - 1] = dpa[ii] + x
	dpa[ii - 1] = min(dpa[ii] + y, dpb[ii - 1] + x)
print(dpb[b])


import sys
(a, b, x, y) = map(int, input().split())
diff = a - b
if diff == 1 or diff == 0:
	print(x)
	return
if diff < 0:
	diff = -diff
	p1 = x + y * diff
	p2 = 2 * diff * x + x
else:
	p1 = x + y * (diff - 1)
	p2 = diff * x + x * (diff - 1)
print(min(p1, p2))


(A, B, X, Y) = map(int, input().split())
if A == B:
	print(X)
elif A > B:
	if 2 * X < Y:
		print(2 * X * (A - B - 1) + X)
	else:
		print(Y * (A - B - 1) + X)
elif 2 * X < Y:
	print(2 * X * (B - A) + X)
else:
	print(Y * (B - A) + X)


(a, b, x, y) = list(map(int, input().split()))
if b > a:
	use_x = x + 2 * x * (b - a)
	use_y = x + y * (b - a)
elif a == b:
	use_x = x
	use_y = x + y
else:
	use_x = x + 2 * x * (a - b - 1)
	use_y = x + y * (a - b - 1)
print(min(use_x, use_y))


(a, b, x, y) = map(int, input().split())
cnt1 = min(abs(a - b - 1), abs(a - b)) * y + x
cnt2 = min(abs(a - b - 1), abs(a - b)) * 2 * x + x
print(min(cnt1, cnt2))