#include <iostream>
#include <cmath> //подключаем для возможности извлечения корня
#include <iomanip> //подключаем, чтобы округлить до определенного количества знаков
using namespace std;
double distance(long long X1, long long Y1, long long X2, long long Y2)
{
return sqrt((X1-X2)*(X1-X2) + (Y1-Y2)*(Y1-Y2));
}
int main() {
long long A, B, C, X1, X2, Y1, Y2, Z2;
double S = 1000000000;
cin >> A >> B >> C >> X1 >> Y1 >> X2 >> Y2 >> Z2;
if (Z2 == 0)
{
S = distance(X1, Y1, X2, Y2);
}
else
{
if (X2 == 0)
{
S = min(distance(X1, Y1, -Z2, Y2), distance(X1, Y1, -Y2, -Z2));
S = min(S, distance(X1, Y1, Y2 - B, B + Z2));
}
if (X2 == A)
{
S = min (distance(X1, Y1, Z2 + A, Y2), distance(X1, Y1, A + Y2, -Z2));
S = min(S, distance(X1, Y1, A + B - Y2, Z2 + B));
}
if (Y2 == 0)
{
S = min(S, distance(X1, Y1, X2, -Z2));
S = min(S, distance(X1, Y1, -Z2, -X2));
S = min(S, distance(X1, Y1, A + Z2, X2 - A));
}
if (Y2 == B)
{
S = min(S, distance(X1, Y1, X2, Z2 + B));
S = min(S, distance(X1, Y1, -Z2, X2 + B));
S = min(S, distance(X1, Y1, A + Z2, B + A - X2));
}
if ((Y2 != 0) && (Y2 != B) && (X2 != 0) && (X2 != A))
{
S = min(C + distance(X1, Y1, X2, Y2), distance(X1, Y1, X2, -Y2 - C));
S = min(S, distance(X1, Y1, X2, 2*B - Y2 + C));
S = min(S, distance(X1, Y1, -X2 - C, Y2));
S = min(S, distance(X1, Y1, 2*A - X2 + C, Y2));
S = min(S, distance(X1, Y1, A + B + C - Y2, A + B - X2));
S = min(S, distance(X1, Y1, A + C + Y2, X2 - A));
S = min(S, distance(X1, Y1, -C - Y2, -X2));
S = min(S, distance(X1, Y1, Y2 - B - C, B + X2));
S = min(S, distance(X1, Y1, A + B - Y2, A + B + C - X2));
S = min(S, distance(X1, Y1, Y2 - B, B + C + X2));
S = min(S, distance(X1, Y1, -Y2, -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