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;
double x[3], y[3], s1, s2, t1, t2;
struct point {
  double x, y;
  point() {}
  point(double x, double y) : x(x), y(y) {}
};
point operator+(point p1, point p2) { return point(p1.x + p2.x, p1.y + p2.y); }
point operator-(point p1, point p2) { return point(p1.x - p2.x, p1.y - p2.y); }
point operator*(point p1, double d) { return point(p1.x * d, p1.y * d); }
point operator/(point p1, double d) { return point(p1.x / d, p1.y / d); }
double cross(point p1, point p2) { return p2.y * p1.x - p1.y * p2.x; }
double dot(point p1, point p2) { return p1.x * p2.x + p1.y * p2.y; }
double triangle(point a, point b, point c) {
  return fabs(a.x * b.y - a.y * b.x + b.x * c.y - b.y * c.x + c.x * a.y -
              c.y * a.x) /
         (2.0);
}
double dcmp(double d) { return (fabs(d) <= 1e-10) ? 0 : (d > 0 ? 1 : -1); }
double helen(double p1, double p2, double p3) {
  double p = (p1 + p2 + p3) / (2.0);
  return sqrt(p * (p - p1) * (p - p2) * (p - p3));
}
point rotate(point p1, double ang) {
  return point(p1.x * cos(ang) - p1.y * sin(ang),
               p1.x * sin(ang) + p1.y * cos(ang));
}
double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
bool get(double x1, double y1, double r1, double x2, double y2, double r2,
         double x3, double y3, double r3) {
  if (dist(x1, y1, x3, y3) <= r1 - r3 && dist(x2, y2, x3, y3) <= r2 - r3)
    return true;
  double tx1, tx2, ty1, ty2;
  if (fabs(x1 - x2) < 1e-10) {
    ty1 = ty2 = (r2 * r2 - r1 * r1 + x1 * x1 + y1 * y1 - x2 * x2 - y2 * y2) /
                (y1 - y2) / 2.0;
    tx1 = x1 - sqrt(r1 * r1 - (ty1 - y1) * (ty1 - y1));
    tx2 = 2 * x1 - tx1;
  } else {
    double kx = (x1 - x2) * 2, ky = (y1 - y2) * 2,
           w = (r2 * r2 + x1 * x1 + y1 * y1 - r1 * r1 - x2 * x2 - y2 * y2);
    double a = (ky * ky) / (kx * kx) + 1,
           b = (-2 * w * ky / (kx * kx)) + (2 * x1 * ky / kx) - (2 * y1),
           c = (w * w / (kx * kx)) - (2 * x1 * w / kx) + x1 * x1 + y1 * y1 -
               r1 * r1;
    double delta = b * b - 4 * a * c;
    if (delta > 1e-10)
      delta = sqrt(delta);
    else
      delta = 0.00000;
    ty1 = (-b - delta) / (2 * a);
    ty2 = (-b + delta) / (2 * a);
    tx1 = (w - ky * ty1) / kx;
    tx2 = (w - ky * ty2) / kx;
  }
  if (dist(x3, y3, tx1, ty1) <= r3) return true;
  if (dist(x3, y3, tx2, ty2) <= r3) return true;
  return false;
}
bool check(double l) {
  if (dist(x[1], y[1], x[2], y[2]) > (s1 + s2 - 2 * l)) return false;
  if (get(x[2], y[2], s1 - l, x[1], y[1], s2 - l, x[0], y[0], l)) return true;
  if (get(x[2], y[2], s1 - l, x[0], y[0], l, x[1], y[1], s2 - l)) return true;
  if (get(x[1], y[1], s2 - l, x[0], y[0], l, x[2], y[2], s1 - l)) return true;
  return false;
}
int main() {
  scanf("%lf %lf", &t1, &t2);
  for (int i = 0; i < 3; i++) scanf("%lf %lf", &x[i], &y[i]);
  s1 = dist(x[0], y[0], x[2], y[2]) + dist(x[2], y[2], x[1], y[1]);
  s2 = dist(x[0], y[0], x[1], y[1]);
  if (s2 + t2 < s1) {
    s1 = dist(x[0], y[0], x[2], y[2]) + t1;
    s2 = dist(x[0], y[0], x[1], y[1]) + t2;
    double l = 0, r = min(s1, s2);
    int beta = 0;
    while (beta <= 10000) {
      double mid = (l + r) / 2.0;
      if (check(mid))
        l = mid;
      else
        r = mid;
      beta++;
    }
    printf("%.9lf\n", l);
  } else
    printf("%.9lf\n", min(s2 + t2, s1 + t1));
  return 0;
}