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;
struct Point {
  double x, y;
  Point(void) {}
  Point(double _x, double _y) : x(_x), y(_y) {}
  friend Point operator-(const Point &a, const Point &b) {
    return Point(a.x - b.x, a.y - b.y);
  }
  friend Point operator+(const Point &a, const Point &b) {
    return Point(a.x + b.x, a.y + b.y);
  }
  friend Point operator*(const Point &a, const double &b) {
    return Point(a.x * b, a.y * b);
  }
  void read() { scanf("%lf%lf", &x, &y); }
} A, B, C;
inline double sqr(double x) { return x * x; }
inline double dist(Point a, Point b) {
  return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
struct Circle {
  Point o;
  double r;
  Circle(void) {}
  Circle(Point _o, double _r) : o(_o), r(_r) {}
  friend pair<Point, Point> jiao(const Circle &a, const Circle &b) {
    double d = dist(a.o, b.o);
    double d1 = (sqr(a.r) - sqr(b.r) + sqr(d)) / 2 / d;
    Point p1 = b.o - a.o;
    Point p2 = Point(-p1.y, p1.x);
    Point now = a.o + p1 * (d1 / dist(a.o, b.o));
    Point res1 = now, res2 = now;
    double d2 = sqrt(sqr(a.r) - sqr(d1));
    if (d2 > 1e-8) {
      res1 = now + p2 * (d2 / sqrt(sqr(p2.x) + sqr(p2.y)));
      res2 = now - p2 * (d2 / sqrt(sqr(p2.x) + sqr(p2.y)));
    }
    return make_pair(res1, res2);
  }
  friend bool operator<(const Circle &a, const Circle &b) { return a.r < b.r; }
};
inline bool In(const Circle &a, const Point &b) { return dist(a.o, b) <= a.r; }
void print(double x) {
  printf("%.10lf\n", x);
  exit(0);
}
double lim1, lim2;
Circle c[3];
inline bool neihan(Circle a, Circle b) {
  return dist(a.o, b.o) <= abs(a.r - b.r);
}
inline bool check2(Circle a, Circle b) {
  return dist(a.o, b.o) <= a.r + b.r + 1e-9;
}
inline bool check(double T) {
  c[0] = Circle(Point(A), T);
  c[1] = Circle(Point(C), lim1 - T - dist(B, C));
  c[2] = Circle(Point(B), lim2 - T);
  sort(c, c + 3);
  if (c[0].r < 0 || c[1].r < 0 || c[2].r < 0) return false;
  if (!check2(c[0], c[1]) || !check2(c[1], c[2]) || !check2(c[0], c[2]))
    return false;
  if (neihan(c[0], c[1])) return check2(c[0], c[2]);
  if (neihan(c[0], c[2])) return check2(c[0], c[1]);
  if (neihan(c[1], c[2])) return check2(c[0], c[1]);
  pair<Point, Point> tmp;
  tmp = jiao(c[0], c[1]);
  if (In(c[2], tmp.first) || In(c[2], tmp.second)) return true;
  tmp = jiao(c[0], c[2]);
  if (In(c[1], tmp.first) || In(c[1], tmp.second)) return true;
  tmp = jiao(c[1], c[2]);
  if (In(c[0], tmp.first) || In(c[0], tmp.second)) return true;
  return false;
}
int main() {
  cin >> lim1 >> lim2;
  A.read();
  B.read();
  C.read();
  lim1 += dist(A, C) + dist(C, B);
  lim2 += dist(A, B);
  if (lim2 >= dist(A, C) + dist(C, B)) print(min(lim1, lim2));
  double l = 0, r = 1000000;
  for (int i = 1; i <= 100000; i++) {
    double mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  print(l);
  return 0;
}