The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t_1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points x = 0 and x = s.

Igor is at the point x_1. He should reach the point x_2. Igor passes 1 meter per t_2 seconds. 

Your task is to determine the minimum time Igor needs to get from the point x_1 to the point x_2, if it is known where the tram is and in what direction it goes at the moment Igor comes to the point x_1.

Igor can enter the tram unlimited number of times at any moment when his and the tram's positions coincide. It is not obligatory that points in which Igor enter and exit the tram are integers. Assume that any boarding and unboarding happens instantly. Igor can move arbitrary along the line (but not faster than 1 meter per t_2 seconds). He can also stand at some point for some time.


-----Input-----

The first line contains three integers s, x_1 and x_2 (2 ≤ s ≤ 1000, 0 ≤ x_1, x_2 ≤ s, x_1 ≠ x_2) — the maximum coordinate of the point to which the tram goes, the point Igor is at, and the point he should come to.

The second line contains two integers t_1 and t_2 (1 ≤ t_1, t_2 ≤ 1000) — the time in seconds in which the tram passes 1 meter and the time in seconds in which Igor passes 1 meter.

The third line contains two integers p and d (1 ≤ p ≤ s - 1, d is either 1 or $- 1$) — the position of the tram in the moment Igor came to the point x_1 and the direction of the tram at this moment. If $d = - 1$, the tram goes in the direction from the point s to the point 0. If d = 1, the tram goes in the direction from the point 0 to the point s.


-----Output-----

Print the minimum time in seconds which Igor needs to get from the point x_1 to the point x_2.


-----Examples-----
Input
4 2 4
3 4
1 1

Output
8

Input
5 4 0
1 2
3 1

Output
7



-----Note-----

In the first example it is profitable for Igor to go by foot and not to wait the tram. Thus, he has to pass 2 meters and it takes 8 seconds in total, because he passes 1 meter per 4 seconds. 

In the second example Igor can, for example, go towards the point x_2 and get to the point 1 in 6 seconds (because he has to pass 3 meters, but he passes 1 meters per 2 seconds). At that moment the tram will be at the point 1, so Igor can enter the tram and pass 1 meter in 1 second. Thus, Igor will reach the point x_2 in 7 seconds in total.

Difficulty: MEDIUM_HARD

Solutions:
(s, x1, x2) = [int(x) for x in input().split()]
(t1, t2) = [int(x) for x in input().split()]
(p, d) = [int(x) for x in input().split()]
di = (x2 - x1 > 0) * 2 - 1
ti = abs(x2 - x1) * t2
if d == di:
	if (p - x1) * d <= 0:
		tt = (x2 - p) * d * t1
	else:
		tt = (2 * s + (x2 - p) * d) * t1
elif d == 1:
	tt = (2 * s - (p + x2)) * t1
else:
	tt = (p + x2) * t1
print(min(ti, tt))


(s, x1, x2) = map(int, input().split())
(tt, t) = map(int, input().split())
(p0, d0) = map(int, input().split())
t0 = abs(x1 - x2) * t
if (x1 - p0) * d0 >= 0:
	t1 = abs(x1 - p0) * tt
	d1 = d0
else:
	if d0 > 0:
		delta = 2 * (s - p0)
	else:
		delta = 2 * p0
	t1 = (abs(x1 - p0) + delta) * tt
	d1 = -d0
p1 = x1
if (x2 - p1) * d1 >= 0:
	t2 = abs(x2 - p1) * tt
else:
	if d1 > 0:
		delta = 2 * (s - p1)
	else:
		delta = 2 * p1
	t2 = (abs(x2 - p1) + delta) * tt
print(min(t0, t1 + t2))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
tt = 0
ti = 0
if p > x1:
	if d == 1:
		if x2 > x1:
			tt = (s + x2 + s - p) * t1
		else:
			tt = (s - p + s - x2) * t1
	elif x2 > x1:
		tt = (p + x2) * t1
	else:
		tt = (p - x2) * t1
elif d == 1:
	if x2 > x1:
		tt = (x2 - p) * t1
	else:
		tt = (s - p + s - x2) * t1
elif x2 > x1:
	tt = (p + x2) * t1
elif x1 == p:
	tt = (x1 - x2) * t1
else:
	tt = (p + s + s - x2) * t1
ti = abs(x2 - x1) * t2
print(min(tt, ti))


ch1 = input()
ch2 = input()
ch3 = input()
t1 = []
t2 = []
t3 = []
t1 = ch1.split(' ')
t2 = ch2.split(' ')
t3 = ch3.split(' ')
(s, x1, x2) = (int(t1[0]), int(t1[1]), int(t1[2]))
(t1, t2) = (int(t2[0]), int(t2[1]))
(d, p) = (int(t3[0]), int(t3[1]))
if t1 >= t2:
	print(abs(x2 - x1) * t2)
else:
	a = abs(x2 - x1) * t2
	if p == 1 and x2 < x1:
		b = (2 * s - d - x2) * t1
	elif p == 1 and x1 < x2:
		if d > x1:
			b = (2 * s - d + x2) * t1
		else:
			b = (x2 - d) * t1
	elif p == -1 and x1 < x2:
		b = (d + x2) * t1
	elif p == -1 and x2 < x1:
		if d < x1:
			b = (2 * s + d - x2) * t1
		else:
			b = (d - x2) * t1
	print(min(a, b))


(s, x1, x2) = [int(i) for i in input().split()]
(t1, t2) = [int(i) for i in input().split()]
(p, d) = [int(i) for i in input().split()]
ig = abs(x1 - x2) * t2
tr = 0
while 1:
	if d == 1:
		if p <= x1 < x2:
			tr += (x2 - p) * t1
			break
		else:
			tr += (s - p) * t1
			p = s
			d = -1
	elif x2 < x1 <= p:
		tr += (p - x2) * t1
		break
	else:
		tr += p * t1
		p = 0
		d = 1
print(min(tr, ig))


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def Waiting(over, pos, d):
	over = over // t1
	if d == 1:
		cur = initial + over
		if cur >= s:
			d = -1
			cur = s - (cur - s)
	else:
		cur = initial - over
		if cur <= 0:
			d = 1
			cur *= -1
	ans = 0
	if d != my_dir:
		if d == 1:
			ans += s - cur
			d = -1
			cur = s
		else:
			ans += cur
			d = 1
			cur = 0
	if d == 1:
		if cur <= pos:
			ans += pos - cur
		else:
			ans += s + pos + (s - cur)
	elif cur >= pos:
		ans += abs(pos - cur)
	else:
		ans += cur + s + (s - pos)
	return ans * t1
(s, x1, x2) = value()
(t1, t2) = value()
(initial, d) = value()
my_dir = 1
if x2 < x1:
	my_dir = -1
ans = abs(x2 - x1) * t2
for i in range(min(x1, x2), max(x2, x1) + 1):
	x1_to_i = abs(i - x1) * t2
	waiting_at_i = Waiting(x1_to_i, i, d)
	i_to_x2 = abs(x2 - i) * t1
	if i == x2:
		waiting_at_i = 0
	ans = min(x1_to_i + waiting_at_i + i_to_x2, ans)
print(ans)


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
alt = abs(x1 - x2) * t2
curpos = p
curtime = 0
inbus = False
while not (curpos == x2 and inbus):
	if curpos == x1:
		inbus = True
	if curpos == s and d == 1:
		d = -1
	if curpos == 0 and d == -1:
		d = 1
	if d == 1:
		curpos += 1
	else:
		curpos -= 1
	curtime += t1
print(min(curtime, alt))


from fractions import Fraction
(s, x1, x2) = [int(v) for v in input().split()]
(t1, t2) = [int(v) for v in input().split()]
(p, d) = [int(v) for v in input().split()]
if x1 > x2:
	(x1, x2) = (s - x1, s - x2)
	p = s - p
	d = -d
if d == -1:
	p = -p
	d = 1
elif d == 1 and p > x1:
	p = -(s - p + s)
if t2 <= t1:
	print((x2 - x1) * t2)
else:
	meet = x1 + Fraction((x1 - p) * t1, t2 - t1)
	if x1 <= meet < x2:
		print((x1 - p) * t1 + (x2 - x1) * t1)
	else:
		print((x2 - x1) * t2)


import sys
from decimal import *

def check(t, w, s, p1, d1, p2, d2):
	if t * w >= 2 * s:
		return True

def main():
	(s, a, b) = map(int, sys.stdin.readline().split())
	(w, v) = map(int, sys.stdin.readline().split())
	(p1, d) = map(int, sys.stdin.readline().split())
	r = abs(a - b) * v
	if v <= w:
		print(r)
		return
	if p1 <= a:
		t_ = 0
		if d == -1 and p1 != a:
			t_ = p1 * w
			a = a - t_ / v
			p1 = 0
			d = 1
		t1 = (a - p1) * v * w / (v + w)
		x1 = a - t1 / v
		t1 += t_
	else:
		t_ = 0
		if d == 1:
			t_ = (s - p1) * w
			a = a + t_ / v
			p1 = s
			d = -1
		t1 = (p1 - a) * v * w / (v + w)
		x1 = a + t1 / v
		t1 += t_
	if d == 1:
		if x1 <= b:
			t2 = (b - x1) * w
		else:
			t2 = (2 * s - x1 - b) * w
	elif x1 >= b:
		t2 = (x1 - b) * w
	else:
		t2 = (x1 + b) * w
	t3 = t1 + t2
	t3i = int(t3)
	if t3i < t3 - 1e-06:
		t3i += 1
	print(min(r, t3i))
main()


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
paidal = abs(x2 - x1) * t2
if t2 <= t1:
	print(paidal)
else:
	ans = 0
	busAayi = 0
	if x1 > p:
		if d == 1:
			ans += abs(x1 - p) * t1
		else:
			ans += abs(2 * p + abs(p - x1)) * t1
			d = 1
	elif x1 == p:
		pass
	elif d == 1:
		ans += abs(2 * (s - p) + abs(p - x1)) * t1
		d = -1
	else:
		ans += abs(x1 - p) * t1
	if x2 > x1:
		if d == 1:
			ans += (x2 - x1) * t1
		else:
			ans += abs(2 * x1 + abs(x1 - x2)) * t1
	elif x2 == x1:
		pass
	elif d == 1:
		ans += abs(2 * (s - x1) + abs(x1 - x2)) * t1
	else:
		ans += abs(x2 - x1) * t1
	print(min(paidal, ans))


def calculate_min_time(s, x1, x2, t1, t2, tx1, d):
	if x1 < x2:
		igor_meters = x2 - x1
	else:
		igor_meters = x1 - x2
	igor_time = igor_meters * t2
	if tx1 < x2:
		if d == 1:
			tram_meters = x2 - tx1
		else:
			tram_meters = tx1 + x2
	elif d == 1:
		tram_meters = s - tx1 + s - x2
	else:
		tram_meters = tx1 - x2
	tram_time = tram_meters * t1
	if igor_time < tram_time:
		return igor_time
	if x1 < x2:
		if tx1 < x2 and tx1 > x1 and (d == 1):
			return min(igor_time, tram_time + 2 * s * t1)
		elif tx1 > x2:
			return min(igor_time, tram_time + 2 * x2 * t1)
	elif tx1 > x2 and tx1 < x1:
		if d == -1:
			return min(igor_time, tram_time + 2 * s * t1)
	elif tx1 < x2:
		return min(igor_time, tram_time + 2 * (s - x2) * t1)
	return tram_time
(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
min_time = calculate_min_time(s, x1, x2, t1, t2, p, d)
print(min_time)


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
d += 1
t = 0
if x1 > x2:
	if d > 0:
		t += (s - p) * t1
		t += (s - x1) * t1
	elif p < x1:
		t += (s * 2 - abs(x1 - p)) * t1
	else:
		t += (p - x1) * t1
elif d == 0:
	t += p * t1
	t += x1 * t1
elif p > x1:
	t += (s * 2 - abs(x1 - p)) * t1
else:
	t += (x1 - p) * t1
print(min(abs(x1 - x2) * t2, abs(x1 - x2) * t1 + t))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
trspeed = 1 / t1
igspeed = 1 / t2
if x1 > x2:
	x1 = s - x1
	x2 = s - x2
	d *= -1
	p = s - p
ans = (x2 - x1) * t2
if d == 1:
	if p <= x1:
		ans = min(ans, t1 * (x2 - p))
	elif trspeed < igspeed:
		t = (igspeed - trspeed) / (p - x1)
		meet = x1 + t * igspeed
		if meet < x2:
			ans = min(ans, t + (x2 - meet) * t1)
	ans = min(ans, t1 * (s - p + s + x2))
else:
	ans = min(ans, (p + x2) * t1)
print(ans)


def solve():
	(tram_stop, igor_pos, igor_desired_point) = map(int, input().split())
	(tram_meter_by_seconds, igor_meter_by_seconds) = map(int, input().split())
	(tram_pos, tram_direction) = map(int, input().split())
	distance = abs(igor_desired_point - igor_pos)
	igor_time_to_walk = distance * igor_meter_by_seconds
	tram_time_to_change_direction = tram_meter_by_seconds * (tram_stop - tram_pos if tram_direction > 0 else tram_pos)
	if distance == 0:
		return 0
	if igor_meter_by_seconds <= tram_meter_by_seconds:
		return igor_time_to_walk
	igor_direction = (igor_desired_point - igor_pos) // distance
	already_walked = 0
	if tram_direction == igor_direction and (tram_pos - igor_pos) * (igor_desired_point - igor_pos) > 0:
		already_walked += tram_time_to_change_direction
		already_walked += tram_stop * tram_meter_by_seconds
		tram_pos = 0 if igor_direction > 0 else tram_stop
	elif tram_direction != igor_direction:
		already_walked += tram_time_to_change_direction
		tram_pos = 0 if igor_direction > 0 else tram_stop
	igor_pos += igor_direction * (already_walked / igor_meter_by_seconds)
	if igor_time_to_walk <= already_walked:
		return igor_time_to_walk
	igor_time_to_walk -= already_walked
	tram_time_to_ride = abs(igor_desired_point - tram_pos) * tram_meter_by_seconds
	return already_walked + min(igor_time_to_walk, tram_time_to_ride)
print(solve())


(s, x1, x2) = list(map(int, input().split()))
(t1, t2) = list(map(int, input().split()))
(p, d) = list(map(int, input().split()))
wt = abs(x2 - x1) * t2
if t2 <= t1:
	print(abs(x2 - x1) * t2)
	return
tt = 0
if d == 1:
	if p <= x2:
		if x1 <= x2 and p <= x1:
			tt = abs(x2 - p) * t1
		elif x1 > x2 and p <= x1:
			tt = (s - p + (s - x2)) * t1
		elif x1 < p:
			tt = (s - p + s + x2) * t1
		else:
			raise Exception()
	elif x1 > x2:
		tt = (s - p + s - x2) * t1
	else:
		tt = (s - p + s + x2) * t1
elif p >= x2:
	if x1 >= x2 and p >= x1:
		tt = abs(x2 - p) * t1
	elif x1 < x2 and p >= x1:
		tt = (p + x2) * t1
	elif x1 > p:
		tt = (p + s + s - x2) * t1
	else:
		raise Exception()
elif x1 < x2:
	tt = (p + x2) * t1
else:
	tt = (p + s + s - x2) * t1
print(min(tt, wt))


(s, x1, x2) = [int(i) for i in input().strip().split()]
(t1, t2) = [int(i) for i in input().strip().split()]
(p, d) = [int(i) for i in input().strip().split()]
d2 = 1 if x2 - x1 > 0 else -1
ans = abs(x2 - x1) * t2
if d == d2 == 1:
	if p <= x1:
		ans = min(ans, (x2 - p) * t1)
	elif p > x1:
		ans = min(ans, (2 * s - p + x2) * t1)
elif d == d2 == -1:
	if p >= x1:
		ans = min(ans, (p - x2) * t1)
	elif p < x1:
		ans = min(ans, (2 * s + p - x2) * t1)
elif d != d2 and d == 1:
	ans = min(ans, (2 * s - p - x2) * t1)
elif d != d2 and d == -1:
	ans = min(ans, (p + x2) * t1)
print(ans)


(s, x1, x2) = [int(i) for i in input().split()]
(t1, t2) = [int(i) for i in input().split()]
(p, d) = [int(i) for i in input().split()]
walk = t2 * abs(x1 - x2)
if t1 >= t2:
	print(walk)
else:
	if x1 <= x2 and x1 >= p and (d > 0) or (x2 <= x1 and x1 <= p and (d < 0)):
		tram = abs(x2 - p)
	elif d < 0 and x1 <= x2:
		tram = x2 + p
	elif d > 0 and x1 >= x2:
		tram = 2 * s - (x2 + p)
	else:
		tram = 2 * s + d * (x2 - p)
	tram *= t1
	print(min(tram, walk))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
ans = abs(x1 - x2) * t2
if d == -1:
	(x1, x2) = (s - x1, s - x2)
	p = s - p
x1t = [(x1 - p) * t1, (2 * s - x1 - p) * t1, (2 * s + x1 - p) * t1]
x2t = [(x2 - p) * t1, (2 * s - x2 - p) * t1, (2 * s + x2 - p) * t1]
while x1t[0] < 0:
	x1t.pop(0)
while x2t[0] < x1t[0]:
	x2t.pop(0)
ans = min(ans, x2t[0])
print(ans)


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
walking_time = abs(x1 - x2) * t2
train_time = 10 ** 6
if x1 <= x2 and d == 1:
	if p <= x1:
		train_time = (x2 - p) * t1
	else:
		train_time = (2 * s + x2 - p) * t1
if x1 <= x2 and d == -1:
	train_time = (p + x2) * t1
if x1 > x2 and d == -1:
	if p >= x1:
		train_time = (p - x2) * t1
	else:
		train_time = (2 * s + p - x2) * t1
if x1 > x2 and d == 1:
	train_time = (s - p + s - x2) * t1
print(min(train_time, walking_time))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
ig = abs(x2 - x1) * t2
tr = ig
if d < 0:
	if x2 < x1:
		if x1 <= p:
			tr = (p - x2) * t1
		else:
			tr = (p + s + (s - x2)) * t1
	else:
		tr = (p + x2) * t1
elif x1 < x2:
	if p <= x1:
		tr = (x2 - p) * t1
	else:
		tr = (s - p + s + x2) * t1
else:
	tr = (s - p + (s - x2)) * t1
ans = min(ig, tr)
print(ans)


(s, x1, x2) = list(map(int, input().split()))
(t1, t2) = list(map(int, input().split()))
(p, d) = list(map(int, input().split()))
if x1 > x2:
	x1 = s - x1
	x2 = s - x2
	d *= -1
	p = s - p

def dist(sx, fx, d, s):
	if d == -1:
		return sx + fx
	elif fx >= sx:
		return fx - sx
	else:
		return 2 * s - abs(fx - sx)
if t1 > t2:
	print(t2 * (x2 - x1))
else:
	print(min(dist(p, x1, d, s) * t1 + (x2 - x1) * t1, (x2 - x1) * t2))


from sys import stdin, stdout
(s, x1, x2) = map(int, stdin.readline().split())
(spt, spp) = map(int, stdin.readline().split())
(p, label) = map(int, stdin.readline().split())
vt = 1 / spt
vp = 1 / spp
ans = abs(x2 - x1) * spp
if vt > vp:
	if label == 1:
		if x2 >= x1:
			if p <= x1:
				t = (x1 - p) / (vt - vp)
				ans = min(ans, t + max(x2 - (x1 + t * vp), 0) * spt)
			else:
				t = (s - p + s) / vt
				t += (x1 + t * vp) / (vt - vp)
				x1 += t * vp
				ans = min(ans, t + max(x2 - x1, 0) * spt)
		else:
			t = (s - p) / vt
			t += (s - (x1 - t * vp)) / (vt - vp)
			x1 -= t * vp
			ans = min(ans, t + max(x1 - x2, 0) * spt)
	elif x2 <= x1:
		if p >= x1:
			t = (p - x1) / (vt - vp)
			ans = min(ans, t + max(x1 - t * vp - x2, 0) * spt)
		else:
			t = (p + s) * spt
			t += (s - (x1 - t * vp)) / (vt - vp)
			ans = min(ans, t + max(x1 - t * vp - x2, 0) * spt)
	else:
		t = p * spt
		t += (x1 + t * vp) / (vt - vp)
		x1 += t * vp
		ans = min(ans, t + max(x2 - x1, 0) * spt)
stdout.write(str(int(ans)))


(s, x1, x2) = list(map(int, input().split()))
(t1, t2) = list(map(int, input().split()))
(p, d) = list(map(int, input().split()))
if x2 < x1:
	(x1, x2) = (s - x1, s - x2)
	d *= -1
	p = s - p
if t2 <= t1:
	print(t2 * abs(x1 - x2))
	return
if p <= x1 and d == 1:
	print(min(t2 * abs(x1 - x2), t1 * abs(p - x2)))
elif d == 1:
	print(min(t2 * abs(x1 - x2), t1 * s + t1 * (s - p) + t1 * abs(x2)))
else:
	print(min(t2 * abs(x1 - x2), t1 * p + t1 * abs(x2)))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
tp = abs(x1 - x2) * t2
if p != x1:
	v = False
else:
	v = True
tt = 0
while 1:
	if p == s:
		d = -1
	if p == 0:
		d = 1
	p += d
	tt += t1
	if p == x1:
		v = True
	if v and p == x2:
		break
print(min(tp, tt))


(s, x1, x2) = (int(z) for z in input().split())
(t1, t2) = (int(z) for z in input().split())
(p, d) = (int(z) for z in input().split())
absol = max(x1 - x2, x2 - x1)
ttoarr = 0
if p > x1 and d > 0:
	ttoarr = (2 * s - p - x1) * t1
	d = -1
elif p < x1 and d < 0:
	ttoarr = (p + x1) * t1
	d = 1
else:
	ute = max(p - x1, x1 - p)
	ttoarr = ute * t1
p = x1
ttocome = 0
if p > x2 and d > 0:
	ttocome = (2 * s - p - x2) * t1
elif p < x2 and d < 0:
	ttocome = (p + x2) * t1
else:
	ute = max(p - x2, x2 - p)
	ttocome = ute * t1
print(min(absol * t2, ttoarr + ttocome))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
ti = abs(x2 - x1) * t2
if d == 1:
	if p > x2:
		tp = (s - p + s - x2) * t1
		if tp < ti and x1 < x2 < p:
			tp += 2 * x2 * t1
	else:
		tp = (x2 - p) * t1
		if tp < ti and x1 < p < x2:
			tp += 2 * s * t1
		elif tp < ti and p < x2 < x1:
			tp += 2 * (s - x2) * t1
elif p > x2:
	tp = (p - x2) * t1
	if tp < ti and x2 < p < x1:
		tp += 2 * s * t1
	elif tp < ti and x1 < x2 < p:
		tp += 2 * x2 * t1
else:
	tp = (p + x2) * t1
	if tp < ti and p < x2 < x1:
		tp += 2 * (s - x2) * t1
print(min(tp, ti))


import sys

def tram(inp):
	inp = list(map(int, inp.split()))
	s = inp[0]
	x1 = inp[1]
	x2 = inp[2]
	t1 = inp[3]
	t2 = inp[4]
	p = inp[5]
	d = inp[6]
	if d < 0:
		x1 = s - x1
		x2 = s - x2
		p = s - p
	walktime = abs(x1 - x2) * t2
	if x2 > x1:
		if p > x1:
			tramtime = (s - p + s + x2) * t1
		else:
			tramtime = (x2 - p) * t1
	else:
		tramtime = (s - p + s - x2) * t1
	return min(walktime, tramtime)
inp = sys.stdin.read()
inp = inp.strip()
print(tram(inp))


f = lambda : map(int, input().split())
(s, x, y) = f()
(a, b) = f()
(p, d) = f()
if x > y:
	(d, p, x, y) = (-d, s - p, s - x, s - y)
print(min((y - x) * b, [2 * s * (p > x) + y - p, y + p][d < 0] * a))


from sys import stdin, setrecursionlimit
from collections import defaultdict
setrecursionlimit(15000)
(s, x1, x2) = list(map(int, stdin.readline().split()))
(t1, t2) = list(map(int, stdin.readline().split()))
(p, d) = list(map(int, stdin.readline().split()))
if t1 >= t2:
	print(abs(x1 - x2) * t2)
	exit()
elif x1 > x2:
	if d == -1:
		if p < x1:
			tram_time = t1 * (abs(p) + s + abs(s - x2))
			print(min(tram_time, abs(x1 - x2) * t2))
		else:
			tram_time = t1 * abs(p - x2)
			print(min(tram_time, abs(x1 - x2) * t2))
	else:
		tram_time = t1 * (abs(s - p) + abs(s - x2))
		print(min(tram_time, abs(x1 - x2) * t2))
elif d == 1:
	if p > x1:
		tram_time = t1 * (abs(s - p) + s + x2)
		print(min(tram_time, abs(x1 - x2) * t2))
	else:
		tram_time = t1 * abs(x2 - p)
		print(min(tram_time, abs(x1 - x2) * t2))
else:
	tram_time = t1 * (abs(p) + x2)
	print(min(tram_time, abs(x1 - x2) * t2))


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

def main():
	(s, x1, x2) = read()
	(t1, t2) = read()
	(p, d) = read()
	if x1 > x2:
		d = -d
		(x1, x2) = (s - x1, s - x2)
		p = s - p
	time_walk = (x2 - x1) * t2
	if d == 1:
		time_tram = (x2 - p) * t1 if p <= x1 else (2 * s - p + x2) * t1
	else:
		time_tram = (p + x2) * t1
	ans = min(time_walk, time_tram)
	print(ans)
main()


(s, x1, x2) = [int(a) for a in input().split()]
(t1, t2) = [int(a) for a in input().split()]
(p, d) = [int(a) for a in input().split()]
if p < x1 and d == -1:
	t = p * t1
	p = 0
	d = 1
elif x1 < p and d == 1:
	t = (s - p) * t1
	p = s
	d = -1
else:
	t = 0
t += t1 * abs(p - x1)
p = x1
if p < x2 and d == -1:
	t += p * t1
	p = 0
	d = 1
elif x2 < p and d == 1:
	t += (s - p) * t1
	p = s
	d = -1
t += t1 * abs(p - x2)
p = x2
igor = t2 * abs(x1 - x2)
print(min(t, igor))


(s, start, finish) = map(int, input().split())
(tramsp, igorsp) = map(int, input().split())
(p, d) = map(int, input().split())
if start == finish:
	print('0')
else:
	if p <= start and d == 1:
		t = (start - p) * tramsp
		nd = d
	elif p >= start and d == -1:
		t = (p - start) * tramsp
		nd = d
	elif p > start and d == 1:
		t = (2 * (s - p) + (p - start)) * tramsp
		nd = -1
	else:
		t = (2 * p + (start - p)) * tramsp
		nd = 1
	if start <= finish and nd == 1:
		t += (finish - start) * tramsp
	elif start >= finish and nd == -1:
		t += (start - finish) * tramsp
	elif start > finish and nd == 1:
		t += (2 * (s - start) + (start - finish)) * tramsp
	else:
		t += (2 * start + (finish - start)) * tramsp
	i = abs(start - finish) * igorsp
	print(min(t, i))


import sys
(s, x1, x2) = list(map(int, sys.stdin.readline().split()))
(t1, t2) = list(map(int, sys.stdin.readline().split()))
(p, d) = list(map(int, sys.stdin.readline().split()))
if x2 > x1:
	dp = 1
else:
	dp = -1
if dp == d:
	if d * p <= d * x1:
		dx2 = abs(x2 - p)
	elif d == 1:
		dx2 = s + (s - p) + x2
	else:
		dx2 = s + p + (s - x2)
elif d == 1:
	dx2 = 2 * s - p - x2
else:
	dx2 = p + x2
tt = dx2 * t1
dx = abs(x1 - x2)
tp = t2 * dx
res = min(tp, tt)
print(res)


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
if x1 < x2:
	if d == 1:
		if p == x1:
			ans1 = t1 * (x2 - x1)
			r = 0
		elif p < x1:
			ans1 = t1 * (x2 - p)
			r = x1 - p
		else:
			ans1 = t1 * (s + x2 + (s - p))
			r = x1 + s + (s - p)
		if t1 < t2:
			t_vstr = r / (1 / t1 - 1 / t2)
			r_p = 1 / t2 * t_vstr
			r_ost = x2 - x1 - r_p
			t_ost = r_ost * t1
			ans2 = round(t_vstr + t_ost)
		else:
			ans2 = (x2 - x1) * t2
		ans3 = (x2 - x1) * t2
	else:
		ans1 = (x2 + p) * t1
		r = p + x1
		if t1 < t2:
			t_vstr = r / (1 / t1 - 1 / t2)
			r_p = 1 / t2 * t_vstr
			r_ost = x2 - x1 - r_p
			t_ost = r_ost * t1
			ans2 = round(t_vstr + t_ost)
		else:
			ans2 = (x2 - x1) * t2
		ans3 = (x2 - x1) * t2
	print(min(ans1, ans2, ans3))
else:
	if d == -1:
		if p == x1:
			ans1 = (x1 - x2) * t1
			r = 0
		elif p > x1:
			ans1 = (p - x2) * t1
			r = p - x1
		else:
			ans1 = (p + s + (s - x2)) * t1
			r = p + s + (s - x1)
		if t1 < t2:
			t_vstr = r / (1 / t1 - 1 / t2)
			r_p = 1 / t2 * t_vstr
			r_ost = x1 - x2 - r_p
			t_ost = r_ost * t1
			ans2 = round(t_vstr + t_ost)
		else:
			ans2 = (x1 - x2) * t2
		ans3 = (x1 - x2) * t2
	else:
		ans1 = (s - p + (s - x2)) * t1
		r = s - p + (s - x1)
		if t1 < t2:
			t_vstr = r / (1 / t1 - 1 / t2)
			r_p = 1 / t2 * t_vstr
			r_ost = x1 - x2 - r_p
			t_ost = r_ost * t1
			ans2 = round(t_vstr + t_ost)
		else:
			ans2 = (x1 - x2) * t2
		ans3 = (x1 - x2) * t2
	print(min(ans1, ans2, ans3))


import math
(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
T1 = t2 * abs(x2 - x1)
if d < 0:
	(x1, x2, p) = (s - x1, s - x2, s - p)
if x2 < x1:
	T2 = t1 * (2 * s - p - x2)
else:
	T2 = t1 * (x2 - p + 2 * s * (x1 < p))
print(min(T1, T2))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
ans = abs(x2 - x1) * t2
xyz = abs(x2 - x1) * t1
if x2 > x1:
	if d == 1:
		if p > x1:
			xyz += (s - p + s + x1) * t1
		else:
			xyz += (x1 - p) * t1
	else:
		xyz += (p + x1) * t1
elif d == 1:
	xyz += (s - p + (s - x1)) * t1
elif p >= x1:
	xyz += (p - x1) * t1
else:
	xyz += (p + s + (s - x1)) * t1
print(min(ans, xyz))


def ri():
	return list(map(int, input().split()))
(s, x1, x2) = ri()
(t1, t2) = ri()
(p, d) = ri()
if t1 >= t2:
	print(t2 * abs(x2 - x1))
	return
m = abs(x2 - x1) * t2
if d > 0:
	if p <= x1 and x1 <= x2:
		m = min(m, (x2 - p) * t1)
	elif p <= x2 and x2 <= x1:
		m = min(m, (s - p + s - x2) * t1)
	elif x1 <= p and p <= x2:
		m = min(m, (s - p + s + x2) * t1)
	elif x1 <= x2 and x2 <= p:
		m = min(m, (s - p + s + x2) * t1)
	elif x2 <= x1 and x1 <= p:
		m = min(m, (s - p + s - x2) * t1)
	elif x2 <= p and p <= x1:
		m = min(m, (s - p + s - x2) * t1)
elif p <= x1 and x1 <= x2:
	m = min(m, (p + x2) * t1)
elif p <= x2 and x2 <= x1:
	m = min(m, (p + s + s - x2) * t1)
elif x1 <= p and p <= x2:
	m = min(m, (p + x2) * t1)
elif x1 <= x2 and x2 <= p:
	m = min(m, (p + x2) * t1)
elif x2 <= x1 and x1 <= p:
	m = min(m, (p - x2) * t1)
elif x2 <= p and p <= x1:
	m = min(m, (p + s + s - x2) * t1)
print(m)


from collections import defaultdict
import sys, os, math

def __starting_point():
	(s, x1, x2) = list(map(int, input().split()))
	(t1, t2) = list(map(int, input().split()))
	(p, d) = list(map(int, input().split()))
	if t1 >= t2:
		print(abs(x2 - x1) * t2)
		return
	if x2 > x1:
		if d == 1:
			if p <= x1:
				t = t1 * (x2 - p)
			else:
				t = t1 * (s + s - p + x2)
		else:
			t = t1 * (p + x2)
	elif d == -1:
		if p >= x1:
			t = t1 * (p - x2)
		else:
			t = t1 * (s + s - x2 + p)
	else:
		t = t1 * (s - p + s - x2)
	print(min(t, abs(x2 - x1) * t2))
__starting_point()


raw = input().split()
s = int(raw[0])
x1 = int(raw[1])
x2 = int(raw[2])
raw = input().split()
t1 = int(raw[0])
t2 = int(raw[1])
raw = input().split()
p = int(raw[0])
d = int(raw[1])
inf = 1000000000
onFoot = abs(x1 - x2)
byTrain = inf
first = 0
save = d
if abs(x2 - (p + d)) >= abs(x2 - (p - d)):
	if d == -1:
		first = p + x2
	else:
		first = s - p + s - x2
	d = d - d * 2
else:
	first = abs(x2 - p)
if d == -1:
	second = first + 2 * x2
	third = second + 2 * (s - x2)
else:
	second = first + 2 * (s - x2)
	third = second + 2 * x2
d = save
if x1 >= min(x2, p) and x1 <= max(x2, p):
	byTrain = first
elif x2 >= min(x1, p) and x2 <= max(x1, p):
	byTrain = second
elif p >= min(x1, x2) and p <= max(x1, x2):
	if abs(1000 * x1 - (1000 * p + d)) >= abs(1000 * x1 - (1000 * p - d)):
		byTrain = third
	else:
		byTrain = first
print(min(t1 * byTrain, t2 * onFoot))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
opt1 = abs(x2 - x1) * t2
tttrain = 0
if x1 == p:
	tttrain = 0
elif x1 < p:
	if d < 0:
		tttrain = (p - x1) * t1
	else:
		tttrain = (s - x1 + s - p) * t1
		d = -d
elif d > 0:
	tttrain = (x1 - p) * t1
else:
	tttrain = (p + x1) * t1
	d = -d
twithtrain = 0
if x1 == x2:
	twithtrain = 0
elif x2 < x1:
	if d < 0:
		twithtrain = (x1 - x2) * t1
	else:
		twithtrain = (s - x1 + s - x2) * t1
elif d > 0:
	twithtrain = (x2 - x1) * t1
else:
	twithtrain = (x1 + x2) * t1
opt2 = tttrain + twithtrain
print(min(opt1, opt2))


from sys import argv, exit

def rstr():
	return input()

def rint():
	return int(input())

def rints():
	return [int(i) for i in input().split(' ')]

def prnt(*args):
	if '-v' in argv:
		print(*args)
l1 = rints()
s = l1[0]
igor = l1[1]
dest = l1[2]
l2 = rints()
tspeed = l2[0]
ispeed = l2[1]
l3 = rints()
tpos = l3[0]
tdir = l3[1]
diff = abs(dest - igor)
itime = ispeed * diff
if tdir > 0:
	tdir *= -1
	igor = s - igor
	dest = s - dest
	tpos = s - tpos
if igor <= tpos and dest < igor:
	prnt('1')
	ttime = tspeed * abs(dest - tpos)
elif igor < tpos and dest > igor:
	prnt('2')
	ttime = tspeed * tpos + dest * tspeed
elif igor > tpos and dest > igor:
	prnt('3')
	ttime = tpos * tspeed + dest * tspeed
elif igor > tpos and dest < igor:
	prnt('3')
	ttime = tpos * tspeed + s * tspeed + (s - dest) * tspeed
elif igor >= tpos and dest > igor:
	ttime = tspeed * tpos + tspeed * dest
else:
	print('something has gone terribly wrong')
	exit(0)
prnt('itime', itime, 'ttime', ttime)
print(min([itime, ttime]))


(s, x1, x2) = [int(i) for i in input().split()]
(t1, t2) = [int(i) for i in input().split()]
(p, d) = [int(i) for i in input().split()]
ans = abs(x1 - x2) * t2
if d == -1:
	(x1, x2) = (s - x1, s - x2)
	p = s - p
x1t = [(x1 - p) * t1, (2 * s - x1 - p) * t1, (2 * s + x1 - p) * t1]
x2t = [(x2 - p) * t1, (2 * s - x2 - p) * t1, (2 * s + x2 - p) * t1]
while x1t[0] < 0:
	x1t.pop(0)
while x2t[0] < x1t[0]:
	x2t.pop(0)
ans = min(ans, x2t[0])
print(ans)


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())

def solve(s, x1, x2, t1, t2, p, d):
	ans = abs(x2 - x1) * t2
	if t1 > t2:
		return ans
	if x1 < x2:
		if p <= x1:
			return min(ans, (x2 - p * d) * t1)
		elif d == 1:
			return min(ans, (s - p + s + x2) * t1)
		else:
			return min(ans, (p + x2) * t1)
	elif p < x1:
		return min(ans, (2 * s - p * d - x2) * t1)
	elif d == 1:
		return min(ans, (s - p + s - x2) * t1)
	else:
		return min(ans, (p - x2) * t1)
print(solve(s, x1, x2, t1, t2, p, d))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
mi = abs(x1 - x2) * t2
t = 0
if (x1 - p) * d >= 0:
	t += abs(x1 - p) * t1
elif d < 0:
	t += (p + x1) * t1
	d *= -1
else:
	t += (2 * s - p - x1) * t1
	d *= -1
if x1 > x2 and d == -1 or (x1 < x2 and d == 1):
	t += abs(x1 - x2) * t1
elif d == -1:
	t += (x1 + x2) * t1
else:
	t += (2 * s - x2 - x1) * t1
if t < mi:
	mi = t
print(mi)


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())

def sol(x1, x2, p, d):
	tt = (x2 - x1) * t2
	if d == 1:
		if p <= x1:
			tt = min(tt, (x2 - p) * t1)
		else:
			tt = min(tt, (s - p) * t1 + s * t1 + x2 * t1)
	if d == -1:
		tt = min(tt, p * t1 + x2 * t1)
	print(tt)
if x1 > x2:
	d = -d
	(x1, x2) = (s - x1, s - x2)
	p = s - p
sol(x1, x2, p, d)


(s, x1, x2) = map(int, input().split(' '))
(t1, t2) = map(int, input().split(' '))
(p, d) = map(int, input().split(' '))
if x2 > p and d == 1:
	train_dis = x2 - p
if x2 < p and d == 1:
	train_dis = s - p + s - x2
if x2 > p and d == -1:
	train_dis = p + x2
if x2 < p and d == -1:
	train_dis = p - x2
if x1 < x2 and p > x1 and (p < x2) and (d == 1):
	train_dis += 2 * s
if x1 < x2 and p > x1 and (p > x2):
	train_dis += 2 * x2
if x1 > x2 and p > x2 and (p < x1) and (d == -1):
	train_dis += 2 * s
if x1 > x2 and p < x1 and (p < x2):
	train_dis += 2 * (s - x2)
train_time = train_dis * t1
igor_dis = abs(x2 - x1)
igor_time = igor_dis * t2
print(min(igor_time, train_time))


(s, x1, x2) = map(float, input().split())
(t1, t2) = map(float, input().split())
(p, d) = map(float, input().split())
x = x2 - x1
adam = abs(x) * t2
tram = 0
if x < 0 and d == 1:
	tram = (abs(x) + s - p + s - x1) * t1
elif x < 0 and d == -1:
	if p >= x1:
		tram = abs(p - x2) * t1
	else:
		tram = (p + s + abs(x) + s - x1) * t1
elif x > 0 and d == 1:
	if x1 >= p:
		tram = (x2 - p) * t1
	else:
		tram = (2 * s + x2 - p) * t1
elif x > 0 and d == -1:
	tram = (p + x2) * t1
print(int(min(tram, adam)))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
if x2 < x1:
	x1 = s - x1
	x2 = s - x2
	p = s - p
	d *= -1
res = (x2 - x1) * t2
if d < 0:
	res = min(res, (p + x2) * t1)
else:
	res = min(res, (s - p + s + x2) * t1)
	if x1 >= p:
		res = min(res, (x2 - p) * t1)
print(res)


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
v1 = t2 * abs(x1 - x2)
v2 = 0
if d == 1 and p <= x1:
	v2 = x1 - p
elif d == 1:
	v2 = s - p + s - x1
	d = -d
elif p >= x1:
	v2 = p - x1
else:
	v2 = p + x1
	d = -d
(p, x1) = (x1, x2)
if d == 1 and p <= x1:
	v2 += x1 - p
elif d == 1:
	v2 += s - p + s - x1
elif p >= x1:
	v2 += p - x1
else:
	v2 += p + x1
v2 *= t1
print(min(v1, v2))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
(tr, pe) = (abs(x1 - x2) * t1, abs(x1 - x2) * t2)
if x2 > x1:
	w = 1
else:
	w = -1
if w != d:
	if d == 1:
		tr += (s - p + s - x1) * t1
	else:
		tr += (p + x1) * t1
elif d == w == 1:
	if p <= x1:
		tr += (x1 - p) * t1
	else:
		tr += (s - p + s + x1) * t1
elif p >= x1:
	tr += (p - x1) * t1
else:
	tr += (p + s + s - x1) * t1
print(min(tr, pe))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
ans = abs(x1 - x2) * t2
if x1 == x2:
	print(0)
elif x1 < x2:
	if d == 1 and p <= x1 or p == 0:
		ans = min(ans, abs(x2 - p) * t1)
	elif d == -1 or p == s:
		ans = min(ans, (p + x2) * t1)
	elif d == 1 and p > x1:
		ans = min(ans, (s - p + s + x2) * t1)
elif d == -1 and p >= x1 or p == s:
	ans = min(ans, abs(p - x2) * t1)
elif d == 1 or p == 0:
	ans = min(ans, (s - p + s - x2) * t1)
elif d == -1 and p < x1:
	ans = min(ans, (p + s + s - x2) * t1)
print(ans)


M = lambda : map(int, input().split())
(s, x1, x2) = M()
(t1, t2) = M()
(p, d) = M()
(v1, v2) = (1 / t1, 1 / t2)
if p <= x1 <= x2 and d > 0:
	path_by_tram = x2 - p
elif p <= x2 <= x1 and d > 0:
	path_by_tram = s - p + s - x2
elif x1 <= p <= x2 and d > 0:
	path_by_tram = 2 * s + x2 - p
elif x1 <= x2 <= p and d > 0:
	path_by_tram = 2 * s - (p - x2)
elif x2 <= x1 <= p and d > 0:
	path_by_tram = 2 * (s - p) + p - x2
elif x2 <= p <= x1 and d > 0:
	path_by_tram = 2 * (s - p) + p - x2
elif p <= x1 <= x2 and d < 0:
	path_by_tram = 2 * p + x2 - p
elif p <= x2 <= x1 and d < 0:
	path_by_tram = 2 * s
elif x1 <= p <= x2 and d < 0:
	path_by_tram = 2 * p + x2 - p
elif x1 <= x2 <= p and d < 0:
	path_by_tram = p + x2
elif x2 <= x1 <= p and d < 0:
	path_by_tram = p - x2
elif x2 <= p <= x1 and d < 0:
	path_by_tram = 2 * s + p - x2
on_foot = abs(x2 - x1) / v2
print(int(min(round(path_by_tram / v1), on_foot)))


def main():
	try:
		while True:
			(s, x1, x2) = list(map(int, input().split()))
			(t1, t2) = list(map(int, input().split()))
			(p, d) = list(map(int, input().split()))

			def travel(src, trg):
				nonlocal d
				if src == trg:
					return 0
				if src < trg:
					if d > 0:
						return trg - src
					else:
						d = 1
						return trg + src
				elif d < 0:
					return src - trg
				else:
					d = -1
					return s - src + s - trg
			a = travel(p, x1)
			b = travel(x1, x2)
			print('%d' % min(abs(x1 - x2) * t2, (a + b) * t1))
	except EOFError:
		pass
main()


(s, x1, x2) = list(map(int, input().split()))
(t1, t2) = list(map(int, input().split()))
(p, d) = list(map(int, input().split()))
if x2 < x1:
	x1 = s - x1
	x2 = s - x2
	p = s - p
	d = -d
vt = 1.0 / t1
vi = 1.0 / t2
xt0 = 0.0
if d == -1:
	xt0 = -p
elif p <= x1:
	xt0 = p
else:
	xt0 = -(s - p) - s

def solve(vt, xt0, vi, x1, x2):
	t1 = (x1 - xt0) / (vt - vi)
	t2 = (x2 - vi * t1 - x1) / vt
	t3 = (x1 - xt0) / (vt + vi)
	t4 = (x2 + vi * t3 - x1) / vt
	return min((x2 - x1) / vi, min(t1 + t2, t3 + t4))
if t2 <= t1:
	print('%.0f' % ((x2 - x1) / vi))
else:
	print('%.0f' % solve(vt, xt0, vi, x1, x2))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
if t1 >= t2:
	print(abs(x1 - x2) * t2)
	exit()
ans = []
ans.append(abs(x1 - x2) * t2)
if d == 1 and p <= x1:
	arrive_1 = abs(x1 - p) * t1
	if x1 < x2:
		arrive_2 = abs(x2 - x1) * t1
	else:
		arrive_2 = abs(2 * s - x1 - x2) * t1
	ans.append(arrive_1 + arrive_2)
if d == 1 and x1 <= p:
	arrive_1 = abs(s - p + s - x1) * t1
	if x1 < x2:
		arrive_2 = (x1 + x2) * t1
	else:
		arrive_2 = abs(x1 - x2) * t1
	ans.append(arrive_1 + arrive_2)
if d == -1 and p <= x1:
	arrive_1 = (p + x1) * t1
	if x1 < x2:
		arrive_2 = abs(x2 - x1) * t1
	else:
		arrive_2 = abs(s - x1 + s - x2) * t1
	ans.append(arrive_1 + arrive_2)
if d == -1 and p >= x1:
	arrive_1 = abs(p - x1) * t1
	if x1 < x2:
		arrive_2 = (x1 + x2) * t1
	else:
		arrive_2 = abs(x1 - x2) * t1
	ans.append(arrive_1 + arrive_2)
print(min(ans))


def codeforces(max_point, start, finish, tram_speed, legs_speed, tram_point, direction):
	if tram_point == start:
		time_to_start = 0
	elif start > tram_point:
		if direction == 1:
			time_to_start = (start - tram_point) * tram_speed
		else:
			direction = -direction
			time_to_start = (start - tram_point) * tram_speed + tram_point * 2 * tram_speed
	elif start < tram_point:
		if direction == -1:
			time_to_start = (tram_point - start) * tram_speed
		else:
			direction = -direction
			time_to_start = (tram_point - start) * tram_speed + (max_point - tram_point) * 2 * tram_speed
	if start == finish:
		time_to_finish = 0
	elif finish > start:
		if direction == 1:
			time_to_finish = (finish - start) * tram_speed
		else:
			direction = -direction
			time_to_finish = (finish - start) * tram_speed + start * 2 * tram_speed
	elif finish < start:
		if direction == -1:
			time_to_finish = (start - finish) * tram_speed
		else:
			direction = -direction
			time_to_finish = (start - finish) * tram_speed + (max_point - start) * 2 * tram_speed
	tram_time = time_to_start + time_to_finish
	legs_time = abs(finish - start) * legs_speed
	return min(tram_time, legs_time)
(max_point, start, finish) = list(map(int, input().split()))
(tram_speed, legs_speed) = list(map(int, input().split()))
(tram_point, direction) = list(map(int, input().split()))
print(codeforces(max_point, start, finish, tram_speed, legs_speed, tram_point, direction))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
res1 = t2 * abs(x2 - x1)
if d < 0:
	(x1, x2, p) = (s - x1, s - x2, s - p)
if x2 < x1:
	res2 = t1 * (2 * s - p - x2)
elif x1 < p:
	res2 = t1 * (x2 - p + 2 * s)
else:
	res2 = t1 * (x2 - p)
print(min(res1, res2))


from collections import defaultdict
import sys, os, math
(s, x1, x2) = list(map(int, input().split()))
(t1, t2) = list(map(int, input().split()))
(p, d) = list(map(int, input().split()))
if t1 >= t2:
	print(abs(x2 - x1) * t2)
	sys.exit(0)
if x2 > x1:
	if d == 1:
		if p <= x1:
			t = t1 * (x2 - p)
		else:
			t = t1 * (s + s - p + x2)
	else:
		t = t1 * (p + x2)
elif d == -1:
	if p >= x1:
		t = t1 * (p - x2)
	else:
		t = t1 * (s + s - x2 + p)
else:
	t = t1 * (s - p + s - x2)
print(min(t, abs(x2 - x1) * t2))


(s, x1, x2) = [int(item) for item in input().split()]
(t1, t2) = [int(item) for item in input().split()]
(p, d) = [int(item) for item in input().split()]
(v1, v2) = (1 / t1, 1 / t2)
k = int((x2 - x1) / abs(x2 - x1))
v2 *= k
t = abs(x2 - x1) * t2
if d == 1:
	if p <= x2:
		if p <= x1 <= x2:
			x = x2 - p
		elif x1 > x2:
			x = s - p + s - x2
		else:
			x = s - p + s + x2
	elif x2 <= x1 <= p:
		x = s - p + s - x2
	elif x1 < x2:
		x = s - p + s + x2
	else:
		x = s - p + s - x2
elif p <= x2:
	if p <= x1 <= x2:
		x = p + x2
	elif x1 > x2:
		x = p + s + s - x2
	else:
		x = p + x2
elif x2 <= x1 <= p:
	x = p - x2
elif x1 < x2:
	x = p + x2
else:
	x = p + s + s - x2
print(min(t, x * t1))


from sys import stdin
(s, x1, x2) = map(int, stdin.readline().split())
(t1, t2) = map(int, stdin.readline().split())
(p, d) = map(int, stdin.readline().split())
if x1 >= x2:
	(x2, x1) = (s - x2, s - x1)
	p = s - p
	d *= -1
tempsPied = (x2 - x1) * t2
if d == -1:
	tempsTram = (p + x2) * t1
elif d == 1 and p > x1:
	tempsTram = (s - p + s + x2) * t1
else:
	tempsTram = (x2 - p) * t1
print(min(tempsPied, tempsTram))


(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
s1 = abs(x1 - x2) * t2
if x1 < x2:
	if d > 0:
		if x1 < p:
			s2 = (s + x2 + s - p) * t1
		else:
			s2 = (x2 - p) * t1
	else:
		s2 = (p + x2) * t1
elif d > 0:
	s2 = (s - p + s - x2) * t1
elif p < x1:
	s2 = (s + s - x2 + p) * t1
else:
	s2 = (p - x2) * t1
print(min(s1, s2))


(s, x1, x2) = input().split(' ')
s = int(s)
x1 = int(x1)
x2 = int(x2)
(v1, v2) = input().split(' ')
v1 = int(v1)
v2 = int(v2)
v1 = 1 / v1
v2 = 1 / v2
(p, d) = input().split(' ')
p = int(p)
d = int(d)
if x1 > x2:
	x1 = s - x1
	x2 = s - x2
	d = -d
	p = s - p
if p <= x1:
	if d == -1:
		x = p + x1
	else:
		x = x1 - p
	t = x / (v1 - v2)
	if x1 + t * v2 <= x2:
		t = t + (x2 - x1 - t * v2) / v1
	else:
		t = (x2 - x1) / v2
else:
	if d == -1:
		x = p - x1
	else:
		x = 2 * s - p - x1
	t = x / (v1 + v2)
	if x1 + t * v2 <= x2:
		t = min(t + (x2 + x1 + t * v2) / v1, (x2 - x1) / v2)
	else:
		t = (x2 - x1) / v2
print(int(t + 0.5))


from math import *
(s, x1, x2) = map(int, input().split())
(t1, t2) = map(int, input().split())
(p, d) = map(int, input().split())
ans = abs(x1 - x2) * t2
if t1 >= t2:
	print(ans)
elif x1 <= x2:
	if d == 1:
		if p <= x1:
			print(min(ans, t1 * (x2 - p)))
		else:
			print(min(ans, t1 * (s - p + s + x2)))
	else:
		print(min(ans, t1 * (p + x2)))
elif d == 1:
	print(min(ans, t1 * (s - p + (s - x2))))
elif p >= x1:
	print(min(ans, t1 * (p - x2)))
else:
	print(min(ans, t1 * (s + p + (s - x2))))


(s, x1, x2) = map(int, input().split(' '))
(t1, t2) = map(int, input().split(' '))
(p, d) = map(int, input().split(' '))
if x2 < x1:
	x1 = s - x1
	x2 = s - x2
	p = s - p
	d *= -1
t_walk = (x2 - x1) * t2
extra = 0
if p > x1 and d == 1:
	extra = 2 * (s - p)
	d = -1
p *= d
t_tram = (x2 - p + extra) * t1
print(min(t_tram, t_walk))


def v11(t):
	if d == 1:
		t += t1 * p
	else:
		t += t1 * (s - p)
	u = t // (s * t1)
	if u % 2 == 0:
		if d == 1:
			return v1 * (t % (s * t1))
		else:
			return s - v1 * (t % (s * t1))
	elif d == 1:
		return s - v1 * (t % (s * t1))
	else:
		return v1 * (t % (s * t1))

def f(t):
	return v11(t) - t * v2 - x1

def dicho(f, t):
	if k * d < 0:
		if d == 1:
			a = t1 * (s - p)
		else:
			a = t1 * p
	elif d == 1:
		if p > x1:
			a = t1 * (2 * s - p)
		else:
			a = 0
	elif p < x1:
		a = t1 * (s + p)
	else:
		a = 0
	if a >= t:
		return t
	b = a + t1 * s
	m = (a + b) // 2
	while b - a > 10 ** (-2):
		m = (a + b) / 2
		if f(a) * f(m) < 0:
			b = m
		elif f(a) * f(m) > 0:
			a = m
		elif f(a) == 0:
			return a
		else:
			return m
	return round(m)
(s, x1, x2) = [int(item) for item in input().split()]
(t1, t2) = [int(item) for item in input().split()]
(p, d) = [int(item) for item in input().split()]
(v1, v2) = (1 / t1, 1 / t2)
k = int((x2 - x1) / abs(x2 - x1))
v2 *= k
t = (x2 - x1) / v2
if abs(v2) > abs(v1):
	print(round(t))
else:
	res = dicho(f, t)
	x = v11(res)
	print(round(min(res + abs(x2 - x) * t1, t)))