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;
int dcmp(double p) {
  if (abs(p) < 1e-12) return 0;
  return p > 1e-12 ? 1 : -1;
}
struct Point {
  double first, second;
  Point() {}
  Point(double first, double second) : first(first), second(second) {}
  friend Point operator-(const Point &a, const Point &b) {
    return Point(a.first - b.first, a.second - b.second);
  }
  friend Point operator+(const Point &a, const Point &b) {
    return Point(a.first + b.first, a.second + b.second);
  }
  friend Point operator*(const Point &a, double p) {
    return Point(a.first * p, a.second * p);
  }
  friend Point operator/(const Point &a, double p) {
    return Point(a.first / p, a.second / p);
  }
} a, b, c;
double hl(double a, double b, double c) {
  double P = (a + b + c) / 2;
  return sqrt(P * (P - a) * (P - b) * (P - c));
}
double dot(const Point &a, const Point &b) {
  return a.first * b.first + a.second * b.second;
}
double jl(const Point &a) { return sqrt(dot(a, a)); }
struct Circle {
  Point first;
  double second;
  Circle() {}
  Circle(const Point &first, const double &second)
      : first(first), second(second) {}
  friend bool operator<(const Circle &a, const Circle &b) {
    return dcmp(a.second - b.second) < 0 &&
           dcmp(b.second - a.second - jl(b.first - a.first)) > 0;
  }
  bool cir_po(const Point &a) { return dcmp(jl(a - first) - second) <= 0; }
} can[5], cir[5];
double t1, t2;
pair<Point, Point> get(const Circle &a, const Circle &b) {
  Point flag = Point(1 << 30, 0);
  Point v = b.first - a.first;
  double dis = jl(v);
  v = v / jl(v);
  if (dcmp(dis - a.second - b.second) > 0) return make_pair(flag, flag);
  if (dcmp(dis - a.second - b.second) == 0)
    return make_pair(a.first + v * a.second, a.first + v * a.second);
  double area = hl(dis, a.second, b.second);
  double h = area * 2 / dis;
  double dis1 = sqrt(a.second * a.second - h * h);
  Point p = a.first + v * dis1;
  Point v1 = Point(-v.second, v.first), v2 = Point(v.second, -v.first);
  return make_pair(p + v1 * h, p + v2 * h);
}
bool check(double p) {
  int tot = 0;
  can[1] = Circle(a, p), can[2] = Circle(b, jl(a - b) + t1 - p),
  can[3] = Circle(c, jl(a - c) + t2 - p);
  if (dcmp(can[1].second) < 0 || dcmp(can[2].second) < 0 ||
      dcmp(can[3].second) < 0)
    return false;
  for (int i = 1; i <= 2; i++)
    for (int j = i + 1; j <= 3; j++)
      if (!(can[i] < can[j]) && !(can[j] < can[i])) {
        pair<Point, Point> ans = get(can[i], can[j]);
        if (!dcmp(ans.first.first - (1 << 30))) return false;
      }
  for (int i = 1, j; i <= 3; i++) {
    for (j = 1; j <= 3; j++)
      if (can[j] < can[i]) break;
    if (j > 3) cir[++tot] = can[i];
  }
  if (tot != 3) return true;
  for (int i = 1; i <= 2; i++)
    for (int j = i + 1; j <= 3; j++) {
      int k = 6 - i - j;
      pair<Point, Point> ans = get(cir[i], cir[j]);
      if (cir[k].cir_po(ans.first) || cir[k].cir_po(ans.second)) return true;
    }
  return false;
}
int main() {
  scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &t2, &t1, &a.first, &a.second, &b.first,
        &b.second, &c.first, &c.second);
  if (dcmp(jl(c - a) + jl(c - b) - t1 - jl(b - a)) <= 0) {
    printf("%.10lf", min(jl(b - a) + t1, jl(c - a) + jl(c - b) + t2));
    return 0;
  }
  double l = 0, r = min(jl(b - a) + t1, jl(c - a) + jl(c - b) + t2);
  while (r - l > 1e-12) {
    double mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.10lf", l);
  return 0;
}