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;
inline bool SR(int &x) { return scanf("%d", &x) == 1; }
inline bool SR(long long &x) { return scanf("%lld", &x) == 1; }
inline bool SR(double &x) { return scanf("%lf", &x); }
inline bool SR(char *s) { return scanf("%s", s); }
inline bool RI() { return 1; }
template <typename I, typename... T>
bool RI(I &x, T &...tail) {
  return SR(x) && RI(tail...);
}
inline void SP(const int x) { printf("%d", x); }
inline void SP(const long long x) { printf("%lld", x); }
inline void SP(const double x) { printf("%.10f", x); }
inline void SP(const char *s) { printf("%s", s); }
inline void PL() { puts(""); }
template <typename I, typename... T>
void PL(const I x, const T... tail) {
  SP(x);
  if (sizeof...(tail)) putchar(' ');
  PL(tail...);
}
const int INF = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3fll;
inline int RAND() {
  static int x = 880301;
  return x = (x * 0xdefacedll + 1ll) % 0x7fffffffll;
}
const long double EPS = 1e-10;
struct Point {
  long double x, y;
  Point() {}
  Point(long double _x, long double _y) : x(_x), y(_y) {}
};
inline Point operator+(const Point p, const Point v) {
  return Point(p.x + v.x, p.y + v.y);
}
inline Point operator-(const Point a, const Point b) {
  return Point(a.x - b.x, a.y - b.y);
}
inline Point operator*(const Point v, const double d) {
  return Point(v.x * d, v.y * d);
}
inline Point operator/(const Point v, const double d) {
  return Point(v.x / d, v.y / d);
}
inline long double dot(const Point a, const Point b) {
  return a.x * b.x + a.y * b.y;
}
inline long double cross(const Point a, const Point b) {
  return a.x * b.y - a.y * b.x;
}
inline long double sqr(long double x) { return x * x; }
inline long double len(Point v) { return sqrtl(dot(v, v)); }
inline long double dist(Point a, Point b) { return len(a - b); }
inline Point rotate(const Point v, const long double ang) {
  return Point(v.x * cosl(ang) - v.y * sinl(ang),
               v.x * sinl(ang) + v.y * cosl(ang));
}
inline int dcmp(long double x) { return fabsl(x) < EPS ? 0 : x > 0 ? 1 : -1; }
struct Circle {
  Point c;
  long double r;
  Circle() {}
  Circle(Point _c, long double _r) : c(_c), r(_r) {}
};
Point A, B, C;
long double t1, t2;
inline bool in_circle(Circle c, Point p) {
  long double d = dist(c.c, p);
  if (dcmp(d - c.r) <= 0)
    return 1;
  else
    return 0;
}
inline vector<Point> circle_intersection(const Circle a, const Circle b) {
  long double d = dist(a.c, b.c);
  vector<Point> res;
  if (dcmp(d - (a.r + b.r)) > 0) return res;
  if (dcmp(d - fabs(a.r - b.r)) < 0) {
    if (a.r > b.r)
      res.push_back(b.c);
    else
      res.push_back(a.c);
    return res;
  }
  if (dcmp(d - fabs(a.r - b.r)) == 0) {
    if (a.r > b.r) {
      Point v = b.c - a.c;
      v = v / len(v) * a.r;
      res.push_back(a.c + v);
    } else {
      Point v = a.c - b.c;
      v = v / len(v) * b.r;
      res.push_back(b.c + v);
    }
    return res;
  }
  if (dcmp(a.r) == 0 && in_circle(b, a.c)) {
    res.push_back(a.c);
    return res;
  }
  if (dcmp(b.r) == 0 && in_circle(a, b.c)) {
    res.push_back(b.c);
    return res;
  }
  if (dcmp(a.r) == 0 || dcmp(b.r) == 0) return res;
  Point v = b.c - a.c;
  if (dcmp(d - (a.r + b.r)) == 0) {
    res.push_back(a.c + v / len(v) * a.r);
    return res;
  }
  double ang = acos((sqr(a.r) + sqr(d) - sqr(b.r)) / (2.0 * a.r * d));
  Point vp = rotate(v, ang);
  vp = vp / len(vp) * a.r;
  res.push_back(a.c + vp);
  vp = rotate(v, -ang);
  vp = vp / len(vp) * a.r;
  res.push_back(a.c + vp);
  return res;
}
inline bool check(long double s) {
  long double ra = s;
  long double rb = t1 - s;
  long double rc = t2 - s - dist(B, C);
  if (ra < 0 || rb < 0 || rc < 0) return 0;
  Circle a(A, ra);
  Circle b(B, rb);
  Circle c(C, rc);
  vector<Point> ps = circle_intersection(a, b);
  for (Point p : ps)
    if (in_circle(c, p)) return 1;
  ps = circle_intersection(a, c);
  for (Point p : ps)
    if (in_circle(b, p)) return 1;
  ps = circle_intersection(b, c);
  for (Point p : ps)
    if (in_circle(a, p)) return 1;
  return 0;
}
int main() {
  cin >> t2 >> t1 >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
  t1 = t1 + dist(A, B);
  t2 = t2 + dist(A, C) + dist(B, C);
  if (t1 >= dist(A, C) + dist(B, C)) {
    cout << fixed << setprecision(10) << min(t1, t2) << '\n';
    return 0;
  }
  long double lb = 0.0, rb = min(t1, t2);
  while (rb - lb > EPS) {
    long double mid = (lb + rb) / 2.0;
    if (check(mid))
      lb = mid;
    else
      rb = mid;
  }
  cout << fixed << setprecision(10) << lb << '\n';
  return 0;
}