#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double distance (double x1,double x2,double y1,double y2)
{
return (sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}
int main() {
cout.precision(2);
double a, b, c;
cin>>a>>b>>c;
double x2, y2, x1, y1, z2;
cin>>x1>>y1;
cin>>x2>>y2>>z2;
double s=250000000;
if (z2==0) s=distance (x1,x2,y1,y2);//"floor" case
else
{
if (x2==0) {x2=-z2; s=distance (x1,x2,y1,y2);}//"left wall" case
if (x2==a) {x2=a+z2; s=distance (x1,x2,y1,y2);}//"right wall" case
if (y2==0) {y2=-z2; s=min(s, distance (x1,x2,y1,y2));}//"near wall" case
if (y2==b) {y2=b+z2; s=min(s, distance (x1,x2,y1,y2));}//"distant wall" case
}
cout<<fixed<<s;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPGNtYXRoPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpkb3VibGUgZGlzdGFuY2UgKGRvdWJsZSB4MSxkb3VibGUgeDIsZG91YmxlIHkxLGRvdWJsZSB5MikKewoJcmV0dXJuIChzcXJ0KCh4MS14MikqKHgxLXgyKSsoeTEteTIpKih5MS15MikpKTsKfQppbnQgbWFpbigpIHsKCWNvdXQucHJlY2lzaW9uKDIpOwoJZG91YmxlIGEsIGIsIGM7CgljaW4+PmE+PmI+PmM7Cglkb3VibGUgeDIsIHkyLCB4MSwgeTEsIHoyOwoJY2luPj54MT4+eTE7CgljaW4+PngyPj55Mj4+ejI7Cglkb3VibGUgcz0yNTAwMDAwMDA7CglpZiAoejI9PTApIHM9ZGlzdGFuY2UgKHgxLHgyLHkxLHkyKTsvLyJmbG9vciIgY2FzZQoJZWxzZQoJewoJCWlmICh4Mj09MCkge3gyPS16Mjsgcz1kaXN0YW5jZSAoeDEseDIseTEseTIpO30vLyJsZWZ0IHdhbGwiIGNhc2UKCQlpZiAoeDI9PWEpIHt4Mj1hK3oyOyBzPWRpc3RhbmNlICh4MSx4Mix5MSx5Mik7fS8vInJpZ2h0IHdhbGwiIGNhc2UKCQlpZiAoeTI9PTApIHt5Mj0tejI7IHM9bWluKHMsIGRpc3RhbmNlICh4MSx4Mix5MSx5MikpO30vLyJuZWFyIHdhbGwiIGNhc2UKCQlpZiAoeTI9PWIpIHt5Mj1iK3oyOyBzPW1pbihzLCBkaXN0YW5jZSAoeDEseDIseTEseTIpKTt9Ly8iZGlzdGFudCB3YWxsIiBjYXNlCgl9Cgljb3V0PDxmaXhlZDw8czsKCXJldHVybiAwOwp9