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 {
  long double x, y;
  Point() {}
  Point(long double _, long double __) : x(_), y(__) {}
  friend istream &operator>>(istream &_, Point &p) { return _ >> p.x >> p.y; }
  friend Point operator+(const Point &p1, const Point &p2) {
    return Point(p1.x + p2.x, p1.y + p2.y);
  }
  friend Point operator-(const Point &p1, const Point &p2) {
    return Point(p1.x - p2.x, p1.y - p2.y);
  }
  friend long double Distance(const Point &p1, const Point &p2) {
    return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
  }
  friend long double Arctan2(const Point &p) { return atan2(p.y, p.x); }
} A, B, C;
struct Interval {
  long double l, r;
  Interval() {}
  Interval(long double _, long double __) : l(_), r(__) {}
  bool In_Interval(long double x) const { return x >= l && x <= r; }
  friend bool Intersect(const Interval &i1, const Interval &i2) {
    return i1.In_Interval(i2.l) || i1.In_Interval(i2.r) || i2.In_Interval(i1.l);
  }
};
struct Circle {
  Point o;
  long double r;
  Circle() {}
  Circle(const Point &_, const long double &__) : o(_), r(__) {}
  friend bool Seperated(const Circle &c1, const Circle &c2) {
    return Distance(c1.o, c2.o) > c1.r + c2.r + 1e-15;
  }
  friend bool Include(const Circle &c1, const Circle &c2) {
    return Distance(c1.o, c2.o) < fabs(c1.r - c2.r);
  }
  friend Interval Get_Intersection(const Circle &c1, const Circle &c2) {
    long double alpha = Arctan2(c2.o - c1.o);
    long double a = c1.r;
    long double b = Distance(c1.o, c2.o) - 1e-15;
    long double c = c2.r;
    long double delta = acos((a * a + b * b - c * c) / (2 * a * b));
    return Interval(alpha - delta, alpha + delta);
  }
};
long double t1, t2;
bool Check(const Circle &c1, const Circle &c2, const Circle &c3) {
  Interval i1 = Get_Intersection(c1, c2);
  Interval i2 = Get_Intersection(c1, c3);
  if (Intersect(i1, i2)) return true;
  i1.l += 2 * 3.1415926535897932, i1.r += 2 * 3.1415926535897932;
  if (Intersect(i1, i2)) return true;
  i1.l -= 4 * 3.1415926535897932;
  i1.r -= 4 * 3.1415926535897932;
  if (Intersect(i1, i2)) return true;
  return false;
}
bool Judge(long double mid) {
  Circle c1(A, mid);
  Circle c2(B, t1 - mid);
  Circle c3(C, t2 - Distance(B, C) - mid);
  if (Seperated(c1, c2) || Seperated(c1, c3) || Seperated(c2, c3)) return false;
  if (Include(c1, c2) || Include(c1, c3) || Include(c2, c3)) return true;
  return Check(c1, c2, c3) || Check(c2, c1, c3) || Check(c3, c1, c2);
}
long double Bisection() {
  long double l = 0, r = min(t1, t2 - Distance(B, C));
  while (r - l > 1e-15) {
    long double mid = (l + r) / 2;
    if (Judge(mid))
      l = mid;
    else
      r = mid;
  }
  return (l + r) / 2;
}
int main() {
  cin >> t2 >> t1 >> A >> B >> C;
  t1 += Distance(A, B);
  t2 += Distance(A, C);
  t2 += Distance(B, C);
  if (t1 >= Distance(A, C) + Distance(B, C))
    return cout << fixed << setprecision(10) << min(t1, t2) << endl, 0;
  cout << fixed << setprecision(10) << Bisection() << endl;
  return 0;
}