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 eps = 1e-12;
double t1, t2, cx, cy, sx, sy, hx, hy, cs, ch, sh;
double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
bool getCirle(double x1, double y1, double r1, double x2, double y2, double r2,
              double &rx1, double &ry1, double &rx2, double &ry2) {
  double vx = x2 - x1, vy = y2 - y1;
  double d = dist(x1, y1, x2, y2);
  if (d > r1 + r2 + eps) return false;
  if (d < r1 - r2 + eps) {
    rx1 = x2 - r2, ry1 = y2;
    rx2 = x2 + r2, ry2 = y2;
    return true;
  } else if (d < r2 - r1 + eps) {
    rx1 = x1 - r1, ry1 = y1;
    rx2 = x1 + r1, ry2 = y1;
    return true;
  }
  vx = vx / d * r1, vy = vy / d * r1;
  double cosa = min(1.0 - eps, (r1 * r1 + d * d - r2 * r2) / r1 / d / 2);
  double sina = sqrt(1 - cosa * cosa);
  rx1 = x1 + vx * cosa - vy * sina, ry1 = y1 + vx * sina + vy * cosa;
  rx2 = x1 + vx * cosa + vy * sina, ry2 = y1 - vx * sina + vy * cosa;
  return true;
}
bool inCircle(double x, double y, double r, double x0, double y0) {
  return (x - x0) * (x - x0) + (y - y0) * (y - y0) <= r * r + eps;
}
bool circleInter(double x1, double y1, double r1, double x2, double y2,
                 double r2, double x3, double y3, double r3) {
  double rx1, ry1, rx2, ry2;
  if (r1 < 0 || r2 < 0 || r3 < 0) return false;
  if (getCirle(x1, y1, r1, x2, y2, r2, rx1, ry1, rx2, ry2)) {
    if (inCircle(x3, y3, r3, rx1, ry1)) return true;
    if (inCircle(x3, y3, r3, rx2, ry2)) return true;
  }
  if (getCirle(x1, y1, r1, x3, y3, r3, rx1, ry1, rx2, ry2)) {
    if (inCircle(x2, y2, r2, rx1, ry1)) return true;
    if (inCircle(x2, y2, r2, rx2, ry2)) return true;
  }
  if (getCirle(x2, y2, r2, x3, y3, r3, rx1, ry1, rx2, ry2)) {
    if (inCircle(x1, y1, r1, rx1, ry1)) return true;
    if (inCircle(x1, y1, r1, rx2, ry2)) return true;
  }
  return false;
}
int main() {
  scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &t1, &t2, &cx, &cy, &hx, &hy, &sx, &sy);
  cs = dist(cx, cy, sx, sy), ch = dist(cx, cy, hx, hy),
  sh = dist(sx, sy, hx, hy);
  if (cs + sh <= ch + t2) {
    printf("%.18lf\n", min(cs + sh + t1, ch + t2));
  } else {
    double begin = 0, end = min(cs + t1, ch + t2), mid;
    while (begin + eps < end) {
      mid = (begin + end) / 2;
      if (circleInter(cx, cy, mid, sx, sy, cs + t1 - mid, hx, hy,
                      ch + t2 - mid)) {
        begin = mid;
      } else {
        end = mid;
      }
    }
    printf("%.10lf\n", begin);
  }
  return 0;
}