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 pi = acos(-1);
struct Point {
  double x, y;
  Point(double a = 0, double b = 0) : x(a), y(b) {}
  inline void read() { scanf("%lf%lf", &x, &y); }
  inline void print() { printf("%.2lf %.2lf\n", x, y); }
  inline Point operator+(const Point &b) { return Point(x + b.x, y + b.y); }
  inline Point operator-(const Point &b) { return Point(x - b.x, y - b.y); }
  inline Point operator*(const double p) { return Point(x * p, y * p); }
  inline Point operator/(const double p) { return Point(x / p, y / p); }
  inline Point operator==(const Point &b) {
    return fabs(x - b.x) < 1e-10 && fabs(y - b.y) < 1e-10;
  }
  inline Point operator<(const Point &b) {
    return x < b.x || (x == b.x && y < b.y);
  }
  inline double ang() { return atan2(y, x); }
} A, B, C;
struct Interval {
  double l, r;
  Interval(double a = 0, double b = 0) : l(a), r(b) {}
  inline bool In_Interval(double x) { return x >= l && x <= r; }
};
struct Circle {
  Point O;
  double r;
  Circle() {}
  Circle(Point O, double r) : O(O), r(r) {}
  inline Point point(double rad) {
    return Point(O.x + r * cos(rad), O.y + r * sin(rad));
  }
};
double t1, t2, L1, L2;
inline double Dot(Point A, Point B) { return A.x * B.x + A.y * B.y; }
inline double Lenth(Point A) { return sqrt(Dot(A, A)); }
Interval Circle_Jiao(Circle c1, Circle c2) {
  double a = c1.r;
  double b = c2.r;
  double c = Lenth(c1.O - c2.O);
  double temp = (c1.O - c2.O).ang();
  double delta = acos((a * a + c * c - b * b) / (2 * a * c));
  return Interval(temp - delta, temp + delta);
}
bool Separate(Circle c1, Circle c2) {
  return Lenth(c1.O - c2.O) > c1.r + c2.r + 1e-10;
}
bool Contain(Circle c1, Circle c2) {
  return Lenth(c1.O - c2.O) < fabs(c1.r - c2.r);
}
bool Interval_Jiao(Interval l1, Interval l2) {
  return l1.In_Interval(l2.l) || l1.In_Interval(l2.r) || l2.In_Interval(l1.l) ||
         l2.In_Interval(l1.r);
}
bool Judge(Circle c1, Circle c2, Circle c3) {
  Interval l1 = Circle_Jiao(c1, c2);
  Interval l2 = Circle_Jiao(c1, c3);
  if (Interval_Jiao(l1, l2)) return 1;
  l1.l += pi * 2;
  l1.r += pi * 2;
  if (Interval_Jiao(l1, l2)) return 1;
  l1.l -= pi * 4;
  l1.r -= pi * 4;
  if (Interval_Jiao(l1, l2)) return 1;
  return 0;
}
bool check(double mid) {
  Circle c1(A, mid);
  Circle c2(B, L1 - mid);
  Circle c3(C, L2 - Lenth(B - C) - mid);
  if (Separate(c1, c2) || Separate(c1, c3) || Separate(c2, c3)) return 0;
  if (Contain(c1, c2) || Contain(c1, c3) || Contain(c2, c3)) return 1;
  if (Judge(c1, c2, c3) || Judge(c2, c1, c3) || Judge(c3, c1, c2)) return 1;
  return 0;
}
void solve() {
  double l = 0, r = min(L1, L2 - Lenth(B - C));
  while (l + 1e-10 < r) {
    double mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.10lf\n", check(r) ? r : l);
}
int main() {
  scanf("%lf%lf", &t2, &t1);
  A.read();
  B.read();
  C.read();
  L1 = t1 + Lenth(A - B);
  L2 = t2 + Lenth(A - C) + Lenth(B - C);
  if (L1 >= Lenth(A - C) + Lenth(B - C))
    printf("%.10lf\n", min(L1, L2));
  else
    solve();
  return 0;
}