Problem: Two neighbours, Alan and Bob, live in the city, where there are three buildings only: a cinema, a shop and the house, where they live. The rest is a big asphalt square. 

Once they went to the cinema, and the film impressed them so deeply, that when they left the cinema, they did not want to stop discussing it.

Bob wants to get home, but Alan has to go to the shop first, and only then go home. So, they agreed to cover some distance together discussing the film (their common path might pass through the shop, or they might walk circles around the cinema together), and then to part each other's company and go each his own way. After they part, they will start thinking about their daily pursuits; and even if they meet again, they won't be able to go on with the discussion. Thus, Bob's path will be a continuous curve, having the cinema and the house as its ends. Alan's path — a continuous curve, going through the shop, and having the cinema and the house as its ends.

The film ended late, that's why the whole distance covered by Alan should not differ from the shortest one by more than t1, and the distance covered by Bob should not differ from the shortest one by more than t2.

Find the maximum distance that Alan and Bob will cover together, discussing the film.

Input

The first line contains two integers: t1, t2 (0 ≤ t1, t2 ≤ 100). The second line contains the cinema's coordinates, the third one — the house's, and the last line — the shop's. 

All the coordinates are given in meters, are integer, and do not exceed 100 in absolute magnitude. No two given places are in the same building.

Output

In the only line output one number — the maximum distance that Alan and Bob will cover together, discussing the film. Output the answer accurate to not less than 4 decimal places.

Examples

Input

0 2
0 0
4 0
-3 0


Output

1.0000000000


Input

0 0
0 0
2 0
1 0


Output

2.0000000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
pair<double, double> operator-(const pair<double, double>& lhs,
                               const pair<double, double>& rhs) {
  return pair<double, double>(lhs.first - rhs.first, lhs.second - rhs.second);
}
pair<double, double> operator+(const pair<double, double>& lhs,
                               const pair<double, double>& rhs) {
  return pair<double, double>(lhs.first + rhs.first, lhs.second + rhs.second);
}
pair<double, double> operator*(double t, pair<double, double> p) {
  return pair<double, double>(t * p.first, t * p.second);
}
pair<double, double> operator/(pair<double, double> p, double t) {
  return pair<double, double>(p.first / t, p.second / t);
}
double Cross(const pair<double, double>& lhs, const pair<double, double>& rhs) {
  return lhs.first * rhs.second - lhs.second * rhs.first;
}
double Dot(const pair<double, double>& lhs, const pair<double, double>& rhs) {
  return lhs.first * rhs.first + lhs.second * rhs.second;
}
double Dist2(const pair<double, double>& lhs, const pair<double, double>& rhs) {
  return Dot(lhs - rhs, lhs - rhs);
}
bool onSegment(pair<double, double> a, pair<double, double> b,
               pair<double, double> c) {
  pair<double, double> v = c - a;
  pair<double, double> w = b - a;
  return Cross(v, w) == 0 && 0 <= Dot(v, w) && Dot(v, w) <= Dot(v, v);
}
bool Intersects(pair<double, double> s0, pair<double, double> e0,
                pair<double, double> s1, pair<double, double> e1) {
  pair<double, double> a = s1 - s0;
  pair<double, double> v = e0 - s0;
  pair<double, double> w = s1 - e1;
  double det = Cross(v, w);
  double t0 = w.second * a.first - w.first * a.second;
  double t1 = -v.second * a.first + v.first * a.second;
  if (det < 0) {
    if (det <= t0 && det <= t1 && t0 <= 0 && t1 <= 0) {
      return true;
    }
  } else if (det > 0) {
    if (0 <= t0 && 0 <= t1 && t0 <= det && t1 <= det) {
      return true;
    }
  }
  return onSegment(s0, s1, e0) || onSegment(s0, e1, e0) ||
         onSegment(s1, s0, e1) || onSegment(s1, e0, e1);
}
bool IntersectLineParam(pair<double, double> s0, pair<double, double> e0,
                        pair<double, double> s1, pair<double, double> e1,
                        double& t0, double& t1) {
  pair<double, double> a = s1 - s0;
  pair<double, double> v = e0 - s0;
  pair<double, double> w = s1 - e1;
  double det = Cross(v, w);
  if (det == 0) {
    return false;
  }
  t0 = Cross(a, w) / det;
  t1 = Cross(v, a) / det;
  return true;
}
pair<double, double> Interpolate(pair<double, double> s, pair<double, double> e,
                                 double t) {
  return (1 - t) * s + t * e;
}
bool IntersectLine(pair<double, double> s0, pair<double, double> e0,
                   pair<double, double> s1, pair<double, double> e1,
                   pair<double, double>& result) {
  double t0, t1;
  if (IntersectLineParam(s0, e0, s1, e1, t0, t1)) {
    result = Interpolate(s0, e0, t0);
    return true;
  }
  return false;
}
bool Intersects(vector<pair<double, double> >& lhs,
                vector<pair<double, double> >& rhs) {
  for (int i = 1; i < lhs.size(); i++) {
    for (int j = 1; j < rhs.size(); j++) {
      if (Intersects(lhs[i], lhs[i - 1], rhs[j], rhs[j - 1])) {
        return true;
      }
    }
  }
  return false;
}
bool IsInside(vector<pair<double, double> >& ps, pair<double, double> p) {
  int count = 0;
  for (int i = 0; i < ps.size(); i++) {
    pair<double, double> a = ps[i];
    pair<double, double> b = ps[(i + 1) % ps.size()];
    if (min(a.first, b.first) <= p.first && p.first < max(a.first, b.first)) {
      double c = Cross(p - a, b - a);
      if (c == 0) {
        return true;
      }
      if (c < 0) {
        count--;
      } else {
        count++;
      }
    } else if (a.first == p.first && b.first == p.first) {
      if (min(a.second, b.second) <= p.second &&
          p.second <= max(a.second, b.second)) {
        return true;
      }
    }
  }
  return count != 0;
}
double area(vector<pair<double, double> > ps) {
  double sum = 0;
  for (int i = 0; i < ps.size(); i++) {
    sum += Cross(ps[i], ps[(i + 1) % ps.size()]);
  }
  return abs(sum) / 2;
}
void full(vector<pair<double, double> >& in,
          vector<pair<double, double> >& out) {
  sort(in.begin(), in.end());
  for (int i = 0; i < in.size(); i++) {
    while (out.size() >= 2) {
      pair<double, double> v = out[out.size() - 1] - out[out.size() - 2];
      pair<double, double> w = in[i] - out[out.size() - 1];
      if (Cross(v, w) >= 0) {
        out.pop_back();
      } else {
        break;
      }
    }
    out.push_back(in[i]);
  }
  for (int i = in.size() - 2, k = max((int)out.size(), 1); i >= 0; i--) {
    while (out.size() > k) {
      pair<double, double> v = out[out.size() - 1] - out[out.size() - 2];
      pair<double, double> w = in[i] - out[out.size() - 1];
      if (Cross(v, w) >= 0) {
        out.pop_back();
      } else {
        break;
      }
    }
    out.push_back(in[i]);
  }
}
void IntersectCircleLine(pair<double, double> c, double r,
                         pair<double, double> s, pair<double, double> v,
                         vector<pair<double, double> >& result) {
  pair<double, double> w = c - s;
  double v2 = Dot(v, v);
  pair<double, double> a = Dot(v, w) * v / v2 + s;
  double d2 = Dist2(c, a);
  if (d2 > r * r) {
    return;
  } else if (d2 == r * r) {
    result.push_back(a);
  }
  pair<double, double> e = v / sqrt(v2);
  double len = sqrt(r * r - d2);
  result.push_back(len * e + a);
  result.push_back((-len) * e + a);
}
void IntersectCircleCircle(pair<double, double> c0, double a,
                           pair<double, double> c1, double b,
                           vector<pair<double, double> >& result) {
  double d2 = Dist2(c0, c1);
  if (d2 > (a + b) * (a + b)) {
    return;
  }
  pair<double, double> s = Interpolate(c0, c1, ((a * a - b * b) / d2 + 1) / 2);
  pair<double, double> d = c0 - c1;
  IntersectCircleLine(c0, a, s, pair<double, double>(d.second, -d.first),
                      result);
}
pair<double, double> rot(pair<double, double> a) {
  return pair<double, double>(-a.second, a.first);
}
void RatioConstantCircle(pair<double, double> c0, double a,
                         pair<double, double> c1, double b,
                         pair<double, double>& c, double& r) {
  if (a > b) {
    swap(c0, c1);
    swap(a, b);
  }
  pair<double, double> p = Interpolate(c0, c1, a / (a + b));
  pair<double, double> q = Interpolate(c0, c1, -a / (b - a));
  c = (p + q) / 2;
  r = sqrt(Dist2(c, p));
}
bool Intersect3Circles(pair<double, double> c0, double r0,
                       pair<double, double> c1, double r1,
                       pair<double, double> c2, double r2) {
  vector<pair<double, double> > result;
  for (int i = 0; i < 3; i++) {
    result.clear();
    IntersectCircleCircle(c0, r0, c1, r1, result);
    for (auto p : result) {
      if (Dist2(p, c2) <= r2 * r2) {
        return true;
      }
    }
    if (Dist2(c0, c1) <= r1 * r1 && Dist2(c0, c2) <= r2 * r2) {
      return true;
    }
    swap(c0, c1);
    swap(c1, c2);
    swap(r0, r1);
    swap(r1, r2);
  }
  return false;
}
const double eps = 1e-12;
int main() {
  cout.precision(10);
  double t1, t2, cx, cy, ax, ay, bx, by;
  cin >> t1 >> t2 >> cx >> cy >> ax >> ay >> bx >> by;
  pair<double, double> c(cx, cy), a(ax, ay), b(bx, by);
  double ac = sqrt(Dist2(c, a)), cb = sqrt(Dist2(c, b)), ba = sqrt(Dist2(b, a));
  double low = 0;
  if (ac + t2 >= cb + ba) {
    low = max(low, min(ac + t2, cb + ba + t1));
  }
  if (cb + t1 >= ac + ba) {
    low = max(low, min(cb + t1 - ba, ac + t2));
  }
  t1 += cb;
  t2 += ac;
  double hi = 300;
  for (int i = 0; i < 1000; i++) {
    double m = (low + hi) / 2;
    bool ok = false;
    if (t1 + eps >= m && t2 + eps >= m) {
      ok = Intersect3Circles(a, t2 - m + eps, b, t1 - m + eps, c, m + eps);
    }
    if (ok) {
      low = m;
    } else {
      hi = m;
    }
  }
  cout << (low + hi) / 2 << endl;
  return 0;
}