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;
const double eps = 1e-11;
struct Point {
  double x, y;
  Point() { x = y = 0.0; }
  Point(double _x, double _y) {
    x = _x;
    y = _y;
  }
  Point operator+(const Point &a) const { return (Point(x + a.x, y + a.y)); }
  Point operator-(const Point &a) const { return (Point(x - a.x, y - a.y)); }
  Point operator*(double k) const { return (Point(x * k, y * k)); }
  Point operator/(double k) const { return (Point(x / k, y / k)); }
  double modul(void) const { return (sqrt(x * x + y * y)); }
  Point unit(void) const { return (*this / modul()); }
  Point perpen(void) const { return (Point(-y, x)); }
};
struct Circle {
  Point center;
  double radius;
  Circle() { radius = 0.0; }
  Circle(Point _center, double _radius) {
    center = _center;
    radius = _radius;
  }
  bool inside(const Point &p) const { return ((center - p).modul() <= radius); }
  bool inside(const Circle &c) const {
    return (c.radius + (center - c.center).modul() <= radius);
  }
  pair<Point, Point> *intersect(const Circle &c) const {
    Point O1 = center;
    Point O2 = c.center;
    double R1 = radius;
    double R2 = c.radius;
    double O1O2 = (O2 - O1).modul();
    if (O1O2 > R1 + R2 + eps) return (NULL);
    if (R1 > O1O2 + R2 + eps) return (NULL);
    if (R2 > R1 + O1O2 + eps) return (NULL);
    double sum = ((1.0 * (R1) * (R1)) - (1.0 * (R2) * (R2))) / O1O2;
    double O1H = (sum + O1O2) / 2;
    double O2H = (sum - O1O2) / 2;
    Point H = O1 + (O2 - O1).unit() * O1H;
    double HA = sqrt((1.0 * (R1) * (R1)) - (1.0 * (O1H - eps) * (O1H - eps)));
    Point A = H + (O2 - O1).unit().perpen() * HA;
    Point B = H - (O2 - O1).unit().perpen() * HA;
    return (new pair<Point, Point>(A, B));
  }
  bool haveSamePoint(const Circle &c) const {
    if (inside(c)) return (true);
    if (c.inside(*this)) return (true);
    return (intersect(c) != NULL);
  }
};
istream &operator>>(istream &is, Point &p) { return (is >> p.x >> p.y); }
ostream &operator<<(ostream &os, const Point &p) {
  return (os << "(" << p.x << "," << p.y << ")");
}
double allowAlen, allowBob;
Point c, s, h;
void init(void) {
  cin >> allowAlen >> allowBob >> c >> h >> s;
  allowAlen += (c - s).modul() + (s - h).modul();
  allowBob += (c - h).modul();
  cerr << setprecision(3) << allowAlen << " " << allowBob << endl;
}
bool intersect(const Circle &c1, const Circle &c2, const Circle &c3) {
  if (c1.inside(c2) || c1.inside(c3)) return (c2.haveSamePoint(c3));
  if (c2.inside(c3) || c2.inside(c1)) return (c3.haveSamePoint(c1));
  if (c3.inside(c1) || c3.inside(c2)) return (c1.haveSamePoint(c2));
  pair<Point, Point> *inter;
  inter = c1.intersect(c2);
  if (inter == NULL) return (false);
  if (c3.inside(inter->first) || c3.inside(inter->second)) return (true);
  inter = c2.intersect(c3);
  if (inter == NULL) return (false);
  if (c1.inside(inter->first) || c1.inside(inter->second)) return (true);
  inter = c3.intersect(c1);
  if (inter == NULL) return (false);
  if (c2.inside(inter->first) || c2.inside(inter->second)) return (true);
  return (false);
}
bool ok(double d) {
  if (d + (s - h).modul() <= allowAlen && d <= allowBob) {
    Circle C(c, d);
    Circle S(s, allowAlen - d - (s - h).modul());
    Circle H(h, allowBob - d);
    if (intersect(C, S, H)) return (true);
  }
  if ((c - s).modul() <= d && d <= allowBob && d <= allowAlen) {
    Circle C(c, d);
    Circle S(s, d - (c - s).modul());
    Circle H(h, min(allowBob - d, allowAlen - d));
    if (intersect(C, S, H)) return (true);
  }
  return (false);
}
void process(void) {
  double L = 0;
  double R = 100000;
  for (int love = 0, _n = (722); love < _n; love = love + 1) {
    double M = (L + R) / 2;
    if (ok(M))
      L = M;
    else
      R = M;
  }
  printf("%.9lf\n", (L + R) / 2);
}
int main(void) {
  init();
  process();
  return 0;
}