def solve(a,i,j,m,n,o,d):
if i>j:
i=a-i
j=a-j
o=a-o
d*=-1
tmp=n*(j-i)
c=0
if d==-1:
c=o+i
elif o<=i:
c=i-o
else:
c=2*a-(o-i)
tmp=min(tmp,(c+j-i)*m)
return tmp
a,i,j=map(int,input().split())
m,n=map(int,input().split())
o,d=map(int,input().split())
print(solve(a,i,j,m,n,o,d))
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
double s, x1, x2, t1, t2, p, d;
cin >> s >> x1 >> x2;
cin >> t1 >> t2;
cin >> p >> d;
double v1 = 1.0 / t1, v2 = 1.0 / t2;
if (x1 < x2)
{
if (v2 >= v1)
{
cout << (x2 - x1) * t2 << endl;
}
else
{
if (d == 1)
{
if (p <= x1)
{
cout << min((x2 - p) * t1, (x2 - x1) * t2) << endl;
}
else
{
double tx = (s)*t1 + (s - p) * t1;
double x1org = x1;
x1 = x1 + (tx / t2);
if (x1 >= x2)
{
cout << (x2 - x1org) * t2 << endl;
}
else
{
cout << min((x2 - x1) * t2, (x2)*t1) + tx << endl;
}
}
}
else
{
double tx = (p)*t1;
double x1org = x1;
x1 = x1 + (tx / t2);
if (x1 >= x2)
{
cout << (x2 - x1org) * t2 << endl;
}
else
{
cout << min((x2 - x1) * t2, (x2)*t1) + tx << endl;
}
}
}
}
else
{ // x2 < x1
if (v2 >= v1)
{
cout << (x1 - x2) * t2 << endl;
}
else
{
if (d == 1)
{
double tx = (s - p) * t1;
double x1org = x1;
x1 = x1 - (tx / t2);
if (x1 <= x2)
{
cout << (x1org - x2) * t2 << endl;
}
else
{
cout << min((x1 - x2) * t2, (s - x2) * t1) + tx << endl;
}
}
else
{
if (p >= x1)
{
cout << min((x1 - x2) * t2, (p - x2) * t1) << endl;
}
else
{
double tx = p * t1 + s * t1;
double x1org = x1;
x1 = x1 - (tx / t2);
if (x1 <= x2)
{
cout << (x1org - x2) * t2 << endl;
}
else
{
cout << min((x1 - x2) * t2, (s - x2) * t1) + tx << endl;
}
}
}
}
}
return 0;
}
1006A - Adjacent Replacements | 1195C - Basketball Exercise |
1206A - Choose Two Numbers | 1438B - Valerii Against Everyone |
822A - I'm bored with life | 9A - Die Roll |
1430B - Barrels | 279B - Books |
1374B - Multiply by 2 divide by 6 | 1093B - Letters Rearranging |
1213C - Book Reading | 1468C - Berpizza |
1546B - AquaMoon and Stolen String | 1353C - Board Moves |
902A - Visiting a Friend | 299B - Ksusha the Squirrel |
1647D - Madoka and the Best School in Russia | 1208A - XORinacci |
1539B - Love Song | 22B - Bargaining Table |
1490B - Balanced Remainders | 264A - Escape from Stones |
1506A - Strange Table | 456A - Laptops |
855B - Marvolo Gaunt's Ring | 1454A - Special Permutation |
1359A - Berland Poker | 459A - Pashmak and Garden |
1327B - Princesses and Princes | 1450F - The Struggling Contestant |